function - How do you get the values greater than a number from a list in scheme? -


how extract , return list numbers greater number found in given list? know how return max different. example (gfifty ‘(a b (c d) 1 56 67 g)) (56 67) in example above, returns list containing values greater 50. teach me master. :)

the idiomatic solution use filter:

(filter (lambda (x) (and (number? x) (> x 50)))         '(a b (c d) 1 56 67 g)) => '(56 67) 

to see how write implementation scratch, take @ this answer. if search recursive (if must search inside sublists), study this other answer.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -