Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ::
- :: gen/problem--bubble-sort.hoon
- :: Sort a list in increasing order via the bubble-sort algorithm.
- ::
- |= a/(list @)
- =/ s/@ (sub (lent a) 1) :: Surface.
- =/ c/@ 0 :: Counter.
- |- ^- (list @)
- ?~ a ~
- ?: =((sub s 1) 0)
- a
- |- ^- (list @)
- ?~ t.a
- [i.a ~ ^$(dec s)] <---
- ?: =(c (sub s 1))
- :: ~& %printed-air
- a
- ?: (gth i.a i.t.a)
- :: ~& %sorting
- [i.t.a $(a [i.a t.t.a], c +(c))]
- :: ~& %printing
- [i.a $(a t.a, c +(c))]
- ::
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement