Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commented factorial:
- :: produce a gate w/ sample n, an unsigned decimal number
- ::
- |= n=@ud
- :: combine unsigned decimal 1 w/ face t with the subject
- ::
- =/ t=@ud 1
- :: produce and evaluate trap. Starting point for recursion.
- ::
- |-
- :: If n is equal to 1, return t, the completed factorial
- ::
- ?: =(n 1)
- t
- :: else tail recurse, decrement n, t as running product of the factorial
- ::
- $(n (dec n), t (mul t n))
- return third element of list without standard library list functions:
- |= input=(list @)
- =/ count 2
- |-
- ?: =(count 0)
- ?~(input ~ i.input)
- $(input ?~(input ~ t.input), count (dec count))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement