Advertisement
keatondunsford

Untitled

Feb 1st, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. ::
  2. :: gen/problem--bubble-sort.hoon
  3. :: Sort a list in increasing order via the bubble-sort algorithm.
  4. ::
  5. |= a/(list @)
  6. =/ s/@ (sub (lent a) 1) :: Surface.
  7. =/ c/@ 0 :: Counter.
  8. |- ^- (list @)
  9. ?~ a ~
  10. ?: =((sub s 1) 0)
  11. a
  12. |- ^- (list @)
  13. ?~ t.a
  14. [i.a ~ ^$(dec s)] <---
  15. ?: =(c (sub s 1))
  16. :: ~& %printed-air
  17. a
  18. ?: (gth i.a i.t.a)
  19. :: ~& %sorting
  20. [i.t.a $(a [i.a t.t.a], c +(c))]
  21. :: ~& %printing
  22. [i.a $(a t.a, c +(c))]
  23. ::
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement