List function

Started by didi, June 30, 2007, 12:04:03 AM

Previous topic - Next topic

didi

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


( 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

#1
looks OK to me!



Using implicit addressing and comparison functions:


(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)... :-)