Skip to content

added lisp,idris,chef,befunge and changed perl a bit#66

Closed
shubhayu-dev wants to merge 1 commit intomanvith12:mainfrom
shubhayu-dev:new_lang
Closed

added lisp,idris,chef,befunge and changed perl a bit#66
shubhayu-dev wants to merge 1 commit intomanvith12:mainfrom
shubhayu-dev:new_lang

Conversation

@shubhayu-dev
Copy link

@shubhayu-dev shubhayu-dev commented Sep 25, 2025

Summary by Sourcery

Implement a polite interaction loop across multiple languages that continuously prompts the user and only exits when the user includes “please” in their input.

New Features:

  • Enhance the Perl script to run an interactive loop that checks for “please” and responds accordingly before exiting
  • Add an Idris implementation of the polite interaction loop
  • Add a Common Lisp implementation of the polite interaction loop
  • Add Befunge, Chef, and SPL implementations of the polite interaction loop

Summary by CodeRabbit

  • New Features
    • Introduces an interactive “politeness check” experience across multiple examples. The app now prompts for input and responds differently based on whether the message includes “please.”
    • Provides clear feedback: a polite acknowledgment when courteous language is used, or a refusal with guidance to try again.
    • Includes a version that continues prompting until a polite request is made.
  • Documentation
    • Adds illustrative scripts and narratives showcasing the polite interaction flow for easier understanding and experimentation.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 25, 2025

Reviewer's Guide

Introduces a consistent polite-loop interaction by upgrading the Perl script and supplying equivalent implementations (or stubs) in multiple languages.

File-Level Changes

Change Details Files
Convert Perl script to interactive polite loop
  • Replace single-run main sub with an infinite while loop
  • Prompt user and normalize input with chomp and lc
  • Detect “please” substring to thank and exit or re-prompt with an apology
Perl.pl
Implement polite-loop in Idris
  • Define politeLoop in IO monad
  • Lowercase input and check for “please” with isInfixOf
  • Recursively re-invoke politeLoop on negative cases
Idris.idr
Implement polite-loop in Lisp
  • Define polite-loop function with display and read-line
  • Convert input to lowercase and test with string-contains
  • Use recursion to repeat until “please” is found, then print response
lsp.lisp
Add stubs for Befunge, Chef, and SPL files
  • Create new empty files for each target language to prepare for future implementations
Befunge.bf93
Chef.chef
SPL.spl

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link

coderabbitai bot commented Sep 25, 2025

Walkthrough

Adds or updates multiple language files to implement a simple interactive “politeness” check: prompt user, read input, normalize case, check for the substring "please", and branch to print one of two fixed responses. Some implementations loop until polite input; others exit after a single branch.

Changes

Cohort / File(s) Summary
Interactive polite loop implementations
Idris.idr, Perl.pl, lsp.lisp
Introduce/read input loop; lowercase input; check contains "please"; on match print polite acknowledgment (and exit/continue as defined); otherwise print refusal and repeat. Idris adds politeLoop : IO (); Perl replaces one-shot with loop; Lisp defines and invokes polite-loop.
New esoteric/script narrative programs with polite branching
Befunge.bf93, Chef.chef, SPL.spl
Add new files encoding a two-branch “polite vs not polite” response flow. Befunge and Chef implement branching output; SPL adds narrative script lines reflecting the two outcomes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant App as Program
  rect rgb(245,248,255)
    note right of App: Start interaction
    User->>App: Input request
    App->>User: "Say something:"
    User-->>App: text
    App->>App: normalize to lowercase
    alt contains "please"
      App-->>User: "Thank you for being polite. Still no."
      note over App,User: End (some variants loop or exit)
    else not polite
      App-->>User: "I'm sorry, I can't assist with it... Try again."
      App->>App: loop/restart (where implemented)
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit taps the Enter key with ease,
Listening for magic words like “please.”
If manners bloom, it bows—yet still says “no,”
If not, it nudges, “try again,” in tow.
Hop, prompt, loop—polite as springtime breeze. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title merely lists the added language files and a minor Perl tweak without clearly summarizing the shared purpose or key functionality introduced across these changes; it is verbose and does not convey the main objective of adding interactive polite-check loops in multiple languages. Please revise the title to concisely reflect the primary change—such as adding interactive polite-response loops in Lisp, Idris, Chef, and Befunge and updating Perl—so that it clearly communicates the shared intent of the new scripts.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. In the meantime, please ensure that your changes align with our [CONTRIBUTING.md]. If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Remove or populate the empty Chef, Befunge, and SPL files instead of committing them as empty placeholders.
  • Verify the Lisp and Idris snippets use the correct string search functions and imports (e.g. string-contains in Lisp and toLower/isInfixOf in Idris) so they actually compile.
  • In the Perl loop, handle EOF or undefined input (e.g. check if <STDIN> returned undef) to avoid an infinite loop when input is closed.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Remove or populate the empty Chef, Befunge, and SPL files instead of committing them as empty placeholders.
- Verify the Lisp and Idris snippets use the correct string search functions and imports (e.g. `string-contains` in Lisp and `toLower`/`isInfixOf` in Idris) so they actually compile.
- In the Perl loop, handle EOF or undefined input (e.g. check if `<STDIN>` returned undef) to avoid an infinite loop when input is closed.

## Individual Comments

### Comment 1
<location> `Idris.idr:8-11` </location>
<code_context>
+politeLoop = do
+  putStr "Say something: "
+  input <- getLine
+  if "please" `isInfixOf` toLower input then
+    putStrLn "Thank you for being polite. Still no."
+  else do
</code_context>

<issue_to_address>
**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.

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

### Comment 2
<location> `lsp.lisp:7` </location>
<code_context>
+    (if (string-contains input "please")
+        (display "Thank you for being polite. Still no.\n")
+        (begin
+          (display "I'm sorry, I can't assist with it. You weren't polite. Try again.\n")
+          (polite-loop)))))
+          
</code_context>

<issue_to_address>
**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.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +8 to +11
input <- getLine
if "please" `isInfixOf` toLower input then
putStrLn "Thank you for being polite. Still no."
else do
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

(if (string-contains input "please")
(display "Thank you for being polite. Still no.\n")
(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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (5)
Perl.pl (1)

6-6: Ensure prompt is visible immediately (autoflush or newline)

Without a newline, the prompt may be buffered. Enable autoflush or print a trailing newline.

Add after use warnings;:

$| = 1; # autoflush STDOUT

Alternatively, change the prompt to include \n.

Idris.idr (2)

7-7: Flush the prompt or print with newline

putStr without newline may buffer the prompt. Prefer putStrLn.

Apply this diff:

-  putStr "Say something: "
+  putStrLn "Say something:"

5-13: Optional: Provide an entrypoint

If this is meant to run standalone, add main.

Example:

main : IO ()
main = politeLoop
SPL.spl (1)

1-12: Confirm intent: prose vs valid SPL

As written, this likely won’t compile as Shakespeare (e.g., string literals, conditionals, and I/O don’t follow SPL semantics). If illustrative prose is intended, all good; if executable SPL is desired, it needs rework (variables, addressing, “Speak your mind,” input verbs).

Happy to provide a compilable SPL version if you confirm the target interpreter.

Chef.chef (1)

7-13: Chef semantics check

Standard Chef doesn’t have direct string I/O or “contains” tests; “Serve” also varies by interpreter. If this is illustrative, fine; if you want an executable Chef program, it will need spec‑compliant steps (mixing bowl operations, baking dish, output).

I can adapt this to a form that runs under a common Chef interpreter—confirm which one you target.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a48982 and f55db89.

📒 Files selected for processing (6)
  • Befunge.bf93 (1 hunks)
  • Chef.chef (1 hunks)
  • Idris.idr (1 hunks)
  • Perl.pl (1 hunks)
  • SPL.spl (1 hunks)
  • lsp.lisp (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Sourcery review

Comment on lines +1 to +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."<
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”?

Comment on lines +2 to +3
(display "Say something: ")
(let ((input (string-downcase (read-line))))
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).

Comment on lines +4 to +5
(if (string-contains input "please")
(display "Thank you for being polite. Still no.\n")
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).

Comment on lines +7 to +9
my $user_input = <STDIN>;
chomp($user_input);
my $user_input_lower = lc($user_input);
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; ... }).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant