Skip to content
Kevin Lindsey edited this page Apr 2, 2014 · 4 revisions

A 'min' function that returns the smaller of two numbers

EM

func min(a, b) {
  (a < b) ? a : b;
}

Ema - long form

asmfunc min(a,b) {
  getSymbol('a')
  getSymbol('b')
  lt
  push({ getSymbol('a') })
  push({ getSymbol('b') })
  ifelse
}

Ema - short form

asmfunc(a,b) {
  ^a ^b lt
  { ^a } { ^b } ifelse
}

Ema - short form 2

asmfunc(a,b) {
  if (^a ^b lt) {
    ^a
  }
  else {
    ^b
  }
}
Clone this wiki locally