Page 1 of 1

List function

Posted: Sat Jun 30, 2007 7:04 am
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 .

Posted: Sat Jun 30, 2007 8:47 am
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)... :-)