-
Notifications
You must be signed in to change notification settings - Fork 11
added lisp,idris,chef,befunge and changed perl a bit #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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."< | ||
| 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." |
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||||||||||||||||
| putStrLn "I'm sorry, I can't assist with it. You weren't polite. Try again." | ||||||||||||||||||||
| politeLoop | ||||||||||||||||||||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle EOF to avoid infinite loop and warnings On Ctrl-D/EOF, 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 |
||
|
|
||
| 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"; | ||
| } | ||
| } | ||
| 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.". |
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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 Add an explicit flush: (display "Say something: ")
+ (flush-output)🤖 Prompt for AI Agents |
||||||||||
| (if (string-contains input "please") | ||||||||||
| (display "Thank you for being polite. Still no.\n") | ||||||||||
|
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the predicate name for the substring check.
Apply this diff: - (if (string-contains input "please")
+ (if (string-contains? input "please")📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| (begin | ||||||||||
| (display "I'm sorry, I can't assist with it. You weren't polite. Try again.\n") | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Program doesn’t read input and uses random branch
There’s no
~/&to read input, and?introduces nondeterminism. Also, the pushed string iseselpa(notpleasereversed).Would you like a minimal Befunge-93 version that actually prompts, reads a line, and checks for “please”?