Draft
S-functor
Loading description...
Recursion
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Example tests are unreadable for solvers. They heavily use
Preloaded
code, which is not available to solvers, and we have to assume behaviour from names. This is not the intent of example tests.Show the
Preloaded
code in the description, or at least explain what everything does, or move the code intoExample tests
( and also intoSubmit tests
, but that's your problem ), or - much preferred - write more readable code inExample tests
. Code duplication is not a ( solver ) problem there; example tests are meant to be readable for solvers, and individual tests should preferably be visible in the window in their entirety, without having to scroll to find definitions of factored out code.sfunctor.test
to the example descriptionad 2: but it is not clear from the description if
Function anonymous
issfunctor
orsfunctor()
, which have different behaviours.Also, the handler must be available immediately, but what is the expected value for
sfunctor.val
? The state is not yet defined at that point.Example test #2 tests
sfunctor.test
. From the description, it is not clear thatsfunctor.anythingButVal
should exist, because it does not yet have state.Either only expect
sfunctor().anythingButVal
to exist, or specify better thatsfunctor.anythingButVal
uncalled should return eithersfunctor()
orsfunctor
( and which one, and possibly why ).The former option would make more sense IMO.
The same goes for
sfunctor.val
- the state is initialised on first call; what is the expected value here, and why? ( I don't know if this is actually tested. )Alternatively,
sfunctor
could immediately have a default state, which might be overwritten normally on first call. But the initial code indicates this is not how things work.All Example tests run in a single
it
. This means I have no clue where this messageis coming from.
Separate example tests should run in separate
it
s, preferably identifying the test in the header ( counting would suffice I guess, though I would like to see "inputs" ).I'll have it fixed within the hour.
done
I like the task, but currently the description essentially requires the solver to imply behaviour from examples. You have a
Task
section which starts with an introductory paragraph, and then just ends? I think you need to move theNotes
to the end of the description, and also actually explain what thissfunctor
actually is before you start clarifying behaviours. Keep in mind that many solvers will likely have even less of an idea of functional programming than you, and so the term "functor" may very well mean nothing to them.With a good description, I think this could be a nice task.
I'll correct the description today with your recommendations in mind.
Can state be
null
? It can't beundefined
, but it would simplify solving if it can't benull
either.technical state can be null or undefined, but I haven't written any tests that lead to such an outcome.
I'll add it to the notes now.
As soon as state is not
undefined
, there is no way to go back to a state ofundefined
.this should be possible with a similar call to
but for simple testing, I'm not testing this behavior.
Yeah, you're right, I forgot about that possibility.
Oh goodness, that means differentiating between
f()
andf(undefined)
.Method of testing is unspecified. What are we supposed to do with "state" ?
please close your issues so I can publish the corrections.
I see the specs have changed. Property
var
must now return the state, and any other property must returnsfunctor
itself. Both seem unnecessary, and the second one seems especially fraught.Implementing the second feature is complicated, the specs are unclear if it should return a clean
sfunctor
or one with the current state, it does not return anything that wasn't already accessible in simpler ways, and it's just an unrelated additional task. "Do one thing, and do it well." Stick to applying functions to values. The state was accessible the original way ( though keeping it inthis.var
is actually not too bad, but then why tell people to keep it in a closure? ), andsfunctor
( with either a new or the current state ) is also already available.I liked the first version better. ( That's my opinion. Other ones may be available. )
I've added a specifics to the description.
I got the idea to extract the state after your questions, so I decided to complicate the task a bit.
I'm sorry you didn't like the updates (
please explain in detail what you mean.
I mean you had a perfectly working way of extracting the state, which allowed keeping state in a closure. Now I have to keep state in
.val
. This adds complexity, but not functionality. It's useless.And if you want
fn.key
, isn't that justfn
? Now I have to wrap things in aProxy
to handle "any (!) property". ( OK, the property access handler that's necessary for this means I can just getval
from the state in the closure again. ) But again, it adds complexity without adding functionality; it's useless.Adding unrelated tasks increasing complexity ( or worse, to add complexity ) is not a good way of upranking your kata.
Empty state is unspecified. "does nothing" is expected to return a value anyway.
I've corrected the description, please see if it's better?
Not seeing any change. Did you
Publish
?i cant publish with issues
I am seeing a second Note now.
"sfunctor” argument
is confusing. Describe as "you just have to keep the state" ?The description update fixed the other issue, not this one.
I think tests expect a state of
{}
for example 1?Yes, the initial state should be
{}
.