Extending assignment Was: Functions with any number of arguments
Subject: Extending assignment Was: Functions with any number of arguments
From: Bill Wood
Date: Thu, 19 Jan 2012 11:04:15 -0600
On Thu, 2012-01-19 at 18:17 +0200, Alexander Klimov wrote:
. . .
> What I wonder, is whether there is a more efficient way to check that
> a list has empty tail than evaluate its length: I guess "empty" should
> be a built-in function:
>
> empty(l) := block([simp:false], ?null(?cdr(l)));
> list_min(l) := block([f:first(l),r:rest(l)],
> if empty(r) then f else min(f, list_min(r)));
> MIN([args]) := list_min(args);
Apparently the set predicate "emptyp" works:
(%i7) emptyp([]);
(%o7) true
(%i8) emptyp([1]);
(%o8) false
(%i9)
In my release (a little out of date) it is documented with sets, where
it is said to work for either sets or lists. If it is not
cross-documented under lists it probably should be.
I have no idea of the efficiency of its implementation.
--
Bill Wood