forked from urbit/archaeology
-
Notifications
You must be signed in to change notification settings - Fork 0
Hoon si
Adam Bliss edited this page Oct 25, 2013
·
1 revision
++ si :: signed integer
|%
++ abs |=(a=@s (add (end 0 1 a) (rsh 0 1 a)))
++ dif |=([a=@s b=@s] (sum a (new !(syn b) (abs b))))
++ dul |=([a=@s b=@s] =+(c=(old a) ?:(-.c (mod +.c b) (sub b +.c))))
++ fra |= [a=@s b=@s]
(new =(0 (mix (syn a) (syn b))) (div (abs a) (abs b)))
++ new |=([a=? b=@] `@s`?:(a (mul 2 b) ?:(=(0 b) 0 +((mul 2 (dec b))))))
++ old |=(a=@s [(syn a) (abs a)])
++ pro |= [a=@s b=@s]
(new =(0 (mix (syn a) (syn b))) (mul (abs a) (abs b)))
++ rem |=([a=@s b=@s] (dif a (pro b (fra a b))))
++ sum |= [a=@s b=@s]
~| %si-sum
=+ [c=(old a) d=(old b)]
?: -.c
?: -.d
(new & (add +.c +.d))
?: (gte +.c +.d)
(new & (sub +.c +.d))
(new | (sub +.d +.c))
?: -.d
?: (gte +.c +.d)
(new | (sub +.c +.d))
(new & (sub +.d +.c))
(new | (add +.c +.d))
++ sun |=(a=@u (mul 2 a))
++ syn |=(a=@s =(0 (end 0 1 a)))
--
Parts of this document are generated automatically. Edits within the comments section will be preserved.