public static ISExpression Eqv(IEnumerable <ISExpression> args) { var a = args.ToArray()[0]; var b = args.ToArray()[1]; if (a.IsBoolean() && b.IsBoolean()) { return(AtomHelper.BooleanFromBool(a.Equals(b))); } if (a.IsSymbol() && b.IsSymbol()) { return(AtomHelper.BooleanFromBool(a.Equals(b))); } if (a.IsNumber() && b.IsNumber()) { NumberAtom x = (NumberAtom)a, y = (NumberAtom)b; return(AtomHelper.BooleanFromBool( x.Val.IsExact == y.Val.IsExact && a.Equals(b))); } if (a.IsChar() && b.IsChar()) { return(AtomHelper.BooleanFromBool(a.Equals(b))); } if (a.IsNil() && b.IsNil()) { return(AtomHelper.BooleanFromBool(true)); } if ((a.IsCons() && b.IsCons())) { return(AtomHelper.BooleanFromBool(((Cons)a) == ((Cons)b))); } if ((a.IsString() && b.IsString())) { return(AtomHelper.BooleanFromBool(((StringAtom)a) == ((StringAtom)b))); } if ((a.IsVector() && b.IsVector())) { return(AtomHelper.BooleanFromBool(((Vector)a) == ((Vector)b))); } if ((a is Procedure && b is Procedure)) { return(AtomHelper.BooleanFromBool(((Procedure)a) == ((Procedure)b))); } if ((a.IsClosure() && b.IsClosure())) { return(AtomHelper.BooleanFromBool(((Closure)a) == ((Closure)b))); } return(AtomHelper.BooleanFromBool(false)); }
public static ISExpression Equal(IEnumerable <ISExpression> args) { var a = args.ToArray()[0]; var b = args.ToArray()[1]; if ( (a.IsCons() && b.IsCons()) || (a.IsVector() && b.IsVector()) || (a.IsString() && b.IsString()) ) { return(AtomHelper.BooleanFromBool((a.Equals(b)))); } else { return(Eqv(args)); } }
public static ISExpression Even(IEnumerable <ISExpression> args) { var n = args.Cast <NumberAtom>().First().Val.Real; return(AtomHelper.BooleanFromBool(n.IsEven || n.IsZero)); }
public static ISExpression Negative(IEnumerable <ISExpression> args) { return(AtomHelper.BooleanFromBool(args.Cast <NumberAtom>().First().Val.Real.IsNegative)); }
public static ISExpression IsNonDecreasing(IEnumerable <ISExpression> args) { return(AtomHelper.BooleanFromBool(args.IsIncreasingOrEqualMontonically())); }
public static ISExpression Equal(IEnumerable <ISExpression> args) { var first = args.First() as NumberAtom; return(AtomHelper.BooleanFromBool(args.Cast <NumberAtom>().All(a => a.Val == first.Val))); }
public static ISExpression IsString(IEnumerable <ISExpression> args) { return(AtomHelper.BooleanFromBool(args.First().IsString())); }
public static ISExpression IsInexact(IEnumerable <ISExpression> args) { var n = args.First() as NumberAtom; return(AtomHelper.BooleanFromBool(args.First().IsNumber() && !n.Val.IsExact)); }
public static ISExpression IsComplex(IEnumerable <ISExpression> args) { var n = args.First() as NumberAtom; return(AtomHelper.BooleanFromBool(args.First().IsComplex())); }
public static ISExpression IsProcedure(IEnumerable <ISExpression> args) { var f = args.First(); return(AtomHelper.BooleanFromBool(f.IsProcedure() || f.IsClosure())); }