List function

For the Compleat Fan
Locked
didi
Posts: 166
Joined: Fri May 04, 2007 8:24 pm
Location: Germany

List function

Post by didi »

For the scaling of a xy-graph , i want the first value of a list that is greater than 'mvalue' .

Code: Select all

( first ( filter (  fn(x) ( > x mvalue) ) prefer-list ) 
This is already my fourth version , it works , but maybe there is an easier/faster way .

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

looks OK to me!

Using implicit addressing and comparison functions:

Code: Select all

(prefer-list (find mvalue prefer-list <))
is probably no faster but possibly slightly neater. However, your version will not complain if there is no matching value - (first '()) is better than (prefer-list nil)... :-)

Locked