Puzzles/Tacit If

From J Wiki
Jump to: navigation, search

Find a tacit expression that computes f y if y is greater than 1, otherwise just return y .

Solution:

f^:(1&<)

For example, the Fibonacci numbers can be computed as (-&2 +&$: -&1) ^: (1&<)


Tacit if is also short circuit boolean operator and.



Contributed by Roger Hui.