Skip to content

Instantly share code, notes, and snippets.

@Qata
Last active January 17, 2017 23:58
Show Gist options
  • Save Qata/ebcb9599036c1eaee236f872f22a650f to your computer and use it in GitHub Desktop.
Save Qata/ebcb9599036c1eaee236f872f22a650f to your computer and use it in GitHub Desktop.
(*!) :: (Ord a, Num a) => a -> a -> a
(*!) a b =
let
multiply _ 0 t = t
multiply a b t = multiply a (b - 1) (t + a)
in
if b >= 0
then multiply a b 0
else negate $ multiply a (negate b) 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment