Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Befunge.bf93
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
>:"eselpa"?v
>"Thank you for being polite. Still no."@
^"I'm sorry, I can't assist with it. You weren't polite. Try again."<
Comment on lines +1 to +3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Program doesn’t read input and uses random branch

There’s no ~/& to read input, and ? introduces nondeterminism. Also, the pushed string is eselpa (not please reversed).

Would you like a minimal Befunge-93 version that actually prompts, reads a line, and checks for “please”?

13 changes: 13 additions & 0 deletions Chef.chef
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Polite Pie.

Ingredients.
say something of string.
polite of string.

Method.
Put "Say something:" into say something.
Mix say something into polite.
If polite contains "please",
Serve "Thank you for being polite. Still no."
Else,
Serve "I'm sorry, I can't assist with it. You weren't polite. Try again."
13 changes: 13 additions & 0 deletions Idris.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Polite

import Data.String

politeLoop : IO ()
politeLoop = do
putStr "Say something: "
input <- getLine
if "please" `isInfixOf` toLower input then
putStrLn "Thank you for being polite. Still no."
else do
Comment on lines +8 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider trimming whitespace from input before processing.

Trimming whitespace before converting to lowercase will help ensure consistent matching and avoid issues with user input.

Suggested change
input <- getLine
if "please" `isInfixOf` toLower input then
putStrLn "Thank you for being polite. Still no."
else do
input <- getLine
let cleanedInput = toLower (trim input)
if "please" `isInfixOf` cleanedInput then
putStrLn "Thank you for being polite. Still no."
else do

putStrLn "I'm sorry, I can't assist with it. You weren't polite. Try again."
politeLoop
18 changes: 13 additions & 5 deletions Perl.pl
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
#!/usr/bin/perl
use strict;
use warnings;

sub main {
my $input = <STDIN>;
print "I'm sorry, I can't assist with it.\n";
}
while (1) {
print "Say something: ";
my $user_input = <STDIN>;
chomp($user_input);
my $user_input_lower = lc($user_input);
Comment on lines +7 to +9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Handle EOF to avoid infinite loop and warnings

On Ctrl-D/EOF, <STDIN> returns undef; chomp/lc will warn and the loop won’t exit.

Apply this diff:

-    my $user_input = <STDIN>;
-    chomp($user_input);
-    my $user_input_lower = lc($user_input);
+    my $user_input = <STDIN>;
+    if (!defined $user_input) { print "\n"; last; }
+    chomp $user_input;
+    my $user_input_lower = lc $user_input;
🤖 Prompt for AI Agents
In Perl.pl around lines 7 to 9, the code reads and processes STDIN without
handling EOF so Ctrl-D returns undef causing chomp/lc warnings and the loop not
to exit; change the read logic to check defined($user_input) immediately after
reading and exit the loop (last/return) when undef is returned, and only call
chomp and lc on a defined $user_input (or refactor to a while defined(my
$user_input = <STDIN>) { chomp $user_input; my $user_input_lower = lc
$user_input; ... }).


main();
if (index($user_input_lower, "please") != -1) {
print "Thank you for being polite. Still no.\n";
last;
} else {
print "I'm sorry, I can't assist with it. You weren't polite. Try again.\n";
}
}
11 changes: 11 additions & 0 deletions SPL.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
The Polite Program.

Romeo, a young man.
Juliet, a charming lady.

Act I: Scene I.
Romeo:
You are as lovely as the sum of please and nothing.
If so, speak your mind.
Else,
Speak "I'm sorry, I can't assist with it. You weren't polite. Try again.".
10 changes: 10 additions & 0 deletions lsp.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(define (polite-loop)
(display "Say something: ")
(let ((input (string-downcase (read-line))))
Comment on lines +2 to +3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Flush the prompt before waiting for input.

Without a newline or explicit flush, many Scheme implementations buffer the prompt, so the user never sees “Say something: ” before the program blocks on read-line.

Add an explicit flush:

   (display "Say something: ")
+  (flush-output)
🤖 Prompt for AI Agents
In lsp.lisp around lines 2–3, the prompt is displayed but not flushed before
read-line, so the prompt may not appear; insert an explicit output flush (e.g.
call the implementation's flush function immediately after the (display "Say
something: ") — or alternatively write a trailing newline and then flush) to
ensure the prompt is visible before blocking on (read-line).

(if (string-contains input "please")
(display "Thank you for being polite. Still no.\n")
Comment on lines +4 to +5
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix the predicate name for the substring check.

string-contains is unresolved in standard Scheme/Racket; the available predicate is string-contains?. This currently raises an unbound identifier error, so the polite check never runs.

Apply this diff:

-    (if (string-contains input "please")
+    (if (string-contains? input "please")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
(if (string-contains input "please")
(display "Thank you for being polite. Still no.\n")
(if (string-contains? input "please")
(display "Thank you for being polite. Still no.\n")
🤖 Prompt for AI Agents
In lsp.lisp around lines 4 to 5, the code uses the non-existent predicate
`string-contains`; replace it with the correct Racket/Scheme predicate
`string-contains?` so the substring check binds and the polite branch runs
(ensure the call signature remains the same and update any other occurrences in
the file).

(begin
(display "I'm sorry, I can't assist with it. You weren't polite. Try again.\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Repeated prompt may be improved by clearing the line or adding spacing.

Frequent loop iterations can clutter the output. Add a blank line or clear the prompt to improve readability.

(polite-loop)))))

(polite-loop)