Stair-climbing puzzle: Difference between revisions

→‎{{header|J}}: use and explain 0:
m (→‎{{header|J}}: simplify step)
(→‎{{header|J}}: use and explain 0:)
Line 162:
'''Solution (Tacit):'''
<lang j>step =: 0.6 > ?@0:
attemptClimb =: [: <:`>:@.step #@(''"_)0:
isNotUpOne =: -.@(+/@])
 
step_up=: (] , attemptClimb)^:isNotUpOne^:_ NB. no variables or numbers</lang>
Note that J's<code>0:</code> verbsis (functions)not musta alwaysnumber takebut ana argumentverb i.e.(function) therethat isreturns nothe suchnumber thingzero asirrespective aof niladicits verbargument(s). VerbsTherefore thatthe ignoreabove theirsolution arguments (e.g.for <code>stepstep_up</code>) achievemeets the samerestrictions of no variables or effectnumbers.
 
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):'''
892

edits