Advertisement
Revolucent

Recaman's Sequence in Hoon

Jan 2nd, 2022
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. :: Recaman's Sequence in Hoon
  2.  
  3. |= limit=@
  4. %- flop
  5. ^- (list @)
  6. ?: =(0 limit)
  7. ~
  8. =/ result=(list @) ~[0]
  9. |-
  10. ?: =((lent result) limit)
  11. result
  12. =/ n (dif:si (new:si & -.result) (new:si & (lent result)))
  13. =/ p (abs:si n)
  14. ?: ?&((syn:si n) =(~ (fand ~[p] result)))
  15. $(result [p result])
  16. $(result [(add -.result (lent result)) result])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement