-
-
Notifications
You must be signed in to change notification settings - Fork 542
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
little schemer: add new problem specs #1285
Conversation
"list": "'Zang'" | ||
}, | ||
"comments": [ | ||
"The primitive null? is defined only for lists." |
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.
Don't test invalid input error conditions
"property": "equality", | ||
"input": { | ||
"function": "car", | ||
"list": ["Immaculate", 23, "G.O.A.T"] |
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.
Either use all strings or numbers in the list, we're not testing lists.
|
"description": "null of non-empty list", | ||
"property": "boolean", | ||
"input": { | ||
"function": "null?", |
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.
Those from languages where ?
is not a valid identifier character will probably object to this.
"cases": [ | ||
{ | ||
"description": "null of non-empty list", | ||
"property": "boolean", |
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.
property tends to describe the name of the function/method being tested.
In this case it would should probably be "is_null" and the function section of input should be removed.
"comments": [ | ||
"The primitive cdr is defined only for non-empty lists. The cdr of any non-empty list is always another list" | ||
], | ||
"expected": -1 |
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.
There's an established format for specifying errors, check the docs.
@@ -0,0 +1,16 @@ | |||
Implement four operations: `null?`, `car`, `cdr` (pronounced could-der), and |
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.
This is a bit confusing since there are 5 things you need to implement.
While I appreciate the effort that has gone into this, I don't think this is a good exercise to add, it's a bit too specific algorithm. See also: #761 (Unless these policies have changed with V2?) |
I infer that the ultimate goal of this exercise is to write the function to determine whether a given list is a list of atoms. I infer this using a few things: A comment in the JSON file:
In the description:
Given this is the case, I would suggest at least two things: Exercise nameI'd suggest the The reason is that the name This will make more sense to those who have not read that particular book. Even for those who have read that particular book, if the book has more than this particular exercise then the more specific name also serves to disambiguate. Intermediate functionsTesting the intermediate functions ( |
"property": "boolean", | ||
"input": { | ||
"function": "atom?", | ||
"list": ["Immaculate", 23] |
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.
since it is expected that inputs to atom?
may be things other than lists, I would say to use something reflective of that fact. Perhaps input
, or if that's deemed too redundant (having an input
nested inside input
) then value
.
@Insti @petertseng Thank you both for all the helpful feedback. The linked discussions were insightful. I'll rethink this exercise through and see if it's still worthwhile. |
I agree with @Insti here. The exercise also feels like it has some overlap with the existing |
I'll close this since it's been a while with no activity. |
Hi, this is a new problem request based around basic recursion. The main inspiration for this exercise comes from the book Little Schemer. Looking forward to feedback. Thanks!