kempe-0.1.1.2: prelude/arith.kmp
import "prelude/fn.kmp"
import "lib/maybe.kmp"
succInt : Int -- Int
=: [ 1 + ]
predInt : Int -- Int
=: [ 1 - ]
isZeroInt : Int -- Bool
=: [ 0 = ]
; More from Mirth
maxInt : Int Int -- Int
=: [ dup2 < if(nip, drop) ]
minInt : Int Int -- Int
=: [ dup2 < if(drop, nip) ]
; checks for division by zero
safeDiv : Int Int -- (Maybe Int)
=: [ dup isZeroInt
if( drop2 Nothing
, / Just
)
]
safeMod : Int Int -- (Maybe Int)
=: [ dup isZeroInt
if( drop2 Nothing
, % Just
)
]