Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Thanks. It looks like I forgot to remove those tests when removing features from the Python port of the "Simple Interactive Interpreter" kata, and then those tests got carried over to the Ruby and Java versions as well. I've removed the tests from all three versions. They were already not present in the JS version.
I will also go ahead and disable
eval
in Python.That's intentional. The "Simple" version is designed to be a superset of the "Simpler" version.
Hey, sorry for the late reply.
fn
should be an unambiguous identifier, and is not specifically reserved by the spec.fn
is not defined in the arguments list.Thanks for the feedback! If you would like to make a detailed case for 1 and/or 4, I'll gladly consider it.
The arity of the function does need to be taken into account. Since only functions which have already been declared may be called, the intepreter has all of the information it needs to make that call.
As a more general example, take the following expression in Polish (prefix) notation:
A prefix interpreter knows that
+
is a binary operator, so it takes the1 2
as the arguments to+
, then*
takes the resulting3 2
, resulting in 6.Likewise, in your example the interpreter knows that
echo
is a unary function, so it takes only the first argument in the stack.Hope that helps. If there was any particular part of the description that led you to believe that arity wouldn't need to be taken into account, please let me know and I will try to clarify that section.
I've added a test for "9", and it works correctly for my solutions in both JavaScript and Python. Note that numbers are defined as as a sequence of digits (with an optional decimal part), and no unary minus operator is defined. Your second two expressions are therefore not valid inputs.
Yes, it is disabled. I'm not sure why it would be enabled when you're running your own tests. Sounds like a site bug to me.
Fixed. It would be really nice if example test cases were run against the reference solution during validation...
Interesting. Apparently the JavaScript and Python test frameworks are a bit inconsistent. Fixed now.
Fixed by disallowing the
require
function.Note the word "interpreter" in the kata title. There is no "compile time"; each statement is evaluated as it is entered. As such, the correct interpretation of the input
a b c
is dependent on the context of the preceding statments.Yes. There is no seperate variable decleration syntax; variables are always created when they are first assigned.
No. Functions here are akin to mathematical functions. That is, a function operates solely on the specified inputs and produces exactly one output. This behavior is covered both by the kata description and the test cases.
I'm inclined to leave this as undefined behavior. My original solution does not support calling functions inside of another function's body, but I don't see the point in explicitly disallowing it either.
Functions calling other functions isn't part of the spec as discussed above. Not testing parameterless functions was an oversight, and I've added a couple tests to cover them.
If someone really wants to write a switch to cover every test case, they're more than welcome to do so. I'm not really interested in thwarting anyone that determined to ignore the spirit of the kata.
I dislike the unpredictableness of randomized tests. A random test is just as likely to allow a submission to pass as it is to generate a valid corner case. I would prefer to identify specific corner cases and add non-random tests for them. I agree that throwing an error is the correct behavior for the input '1 2', and I have added a test to that effect. I'm happy to add tests for other specific issues that you can come up with as well.
Thanks for your feedback. I found and removed two references to functions in the description.
You should be able to click "View Solution" right below my comment.
Thanks! I'm very pleased that you enjoyed it.
I've fixed the grammatical errors and added two additional tests that combine method chaining and invalid arg counts.
Thanks. Disabled Function as well now. ;)
Loading more items...