Exemple #1
0
// =:=/2
func BuiltinNumericEquals(m Machine, args []term.Term) ForeignReturn {
	// evaluate each arithmetic argument
	a, err := term.ArithmeticEval(args[0])
	MaybePanic(err)
	b, err := term.ArithmeticEval(args[1])
	MaybePanic(err)

	// perform the actual comparison
	if term.NumberCmp(a, b) == 0 {
		return ForeignTrue()
	}
	return ForeignFail()
}
Exemple #2
0
// is/2
func BuiltinIs(m Machine, args []term.Term) ForeignReturn {
	value := args[0]
	expression := args[1]
	num, err := term.ArithmeticEval(expression)
	MaybePanic(err)
	return ForeignUnify(value, num)
}