Skip to main content
Notice removed Reward existing answer by DLosc
Bounty Ended with Andrew Bayly's answer chosen by DLosc
Notice added Reward existing answer by DLosc
Bounty Started worth 500 reputation by DLosc
Notice removed Reward existing answer by DLosc
Bounty Ended with emanresu A's answer chosen by DLosc
Notice added Reward existing answer by DLosc
Bounty Started worth 500 reputation by DLosc
Notice removed Reward existing answer by DLosc
Bounty Ended with emanresu A's answer chosen by DLosc
Notice added Reward existing answer by DLosc
Bounty Started worth 500 reputation by DLosc
Notice removed Reward existing answer by DLosc
Bounty Ended with emanresu A's answer chosen by DLosc
Notice added Reward existing answer by DLosc
Bounty Started worth 200 reputation by DLosc
Broadened acceptable I/O formats
Source Link
DLosc
  • 39.2k
  • 5
  • 83
  • 141

Updated June 2022 to be more flexible

Your interpreter may read the program from stdin or fromshould input a file specified via stdin or command-line argument. After evaluatingtinylisp program in one of two ways:

  • directly, as a multiline string, or
  • indirectly, as the name of a file containing the tinylisp program.

It should evaluate each expression, it should output in the program one by one, outputting each result of that expression to stdout with a trailing newline.

All default input and output methods are acceptable. Your submission may be a full program or a function.

Your interpreter may read the program from stdin or from a file specified via stdin or command-line argument. After evaluating each expression, it should output the result of that expression to stdout with a trailing newline.

Updated June 2022 to be more flexible

Your interpreter should input a tinylisp program in one of two ways:

  • directly, as a multiline string, or
  • indirectly, as the name of a file containing the tinylisp program.

It should evaluate each expression in the program one by one, outputting each result with a trailing newline.

All default input and output methods are acceptable. Your submission may be a full program or a function.

Added lisp tag
Link
DLosc
  • 39.2k
  • 5
  • 83
  • 141
Clarification
Source Link
DLosc
  • 39.2k
  • 5
  • 83
  • 141
  • An integer literal evaluates to itself.
  • The empty list () evaluates to itself.
  • A list of one or more items treatsevaluates its first item and treats it as a function or macro and calls, calling it with the remaining items as arguments. If the item is not a function/macro, the behavior is undefined.
  • A symbol evaluates as a name, giving the value bound to that name in the current function. If the name is not defined in the current function, it evaluates to the value bound to it at global scope. If the name is not defined at current or global scope, the result is undefined (reference implementation gives an error message and returns nil).
  • An integer literal evaluates to itself.
  • The empty list () evaluates to itself.
  • A list of one or more items treats its first item as a function or macro and calls it with the remaining items as arguments.
  • A symbol evaluates as a name, giving the value bound to that name in the current function. If the name is not defined in the current function, it evaluates to the value bound to it at global scope. If the name is not defined at current or global scope, the result is undefined (reference implementation gives an error message and returns nil).
  • An integer literal evaluates to itself.
  • The empty list () evaluates to itself.
  • A list of one or more items evaluates its first item and treats it as a function or macro, calling it with the remaining items as arguments. If the item is not a function/macro, the behavior is undefined.
  • A symbol evaluates as a name, giving the value bound to that name in the current function. If the name is not defined in the current function, it evaluates to the value bound to it at global scope. If the name is not defined at current or global scope, the result is undefined (reference implementation gives an error message and returns nil).
Clarified that parameter lists must be non-empty
Source Link
DLosc
  • 39.2k
  • 5
  • 83
  • 141
Loading
Pulled scope rules out into their own section
Source Link
DLosc
  • 39.2k
  • 5
  • 83
  • 141
Loading
Tweeted twitter.com/StackCodeGolf/status/661830526567862272
Source Link
DLosc
  • 39.2k
  • 5
  • 83
  • 141
Loading