Stair-climbing puzzle: Difference between revisions
Content deleted Content added
m →{{header|J}}: simplify step |
→{{header|J}}: use and explain 0: |
||
Line 162: | Line 162: | ||
'''Solution (Tacit):''' |
'''Solution (Tacit):''' |
||
<lang j>step =: 0.6 > ?@0: |
<lang j>step =: 0.6 > ?@0: |
||
attemptClimb =: [: <:`>:@.step |
attemptClimb =: [: <:`>:@.step 0: |
||
isNotUpOne =: -.@(+/@]) |
isNotUpOne =: -.@(+/@]) |
||
step_up=: (] , attemptClimb)^:isNotUpOne^:_ |
step_up=: (] , attemptClimb)^:isNotUpOne^:_</lang> |
||
Note that |
Note that <code>0:</code> is not a number but a verb (function) that returns the number zero irrespective of its argument(s). Therefore the above solution for <code>step_up</code> meets the restrictions of no variables or numbers. |
||
J's verbs (functions) always take an argument i.e. there is no such thing as a niladic verb. Verbs that ignore their arguments (e.g. <code>step</code> and <code>attemptClimb</code>) achieve the same effect. |
|||
'''Solution (Explicit):''' |
'''Solution (Explicit):''' |