numbas / Numbas

A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
http://www.numbas.org.uk
Apache License 2.0
197 stars 118 forks source link

A JME function `partition(list, name, condition)` which splits a list into elements that satisfy the condition and those that don't #1088

Closed christianp closed 1 month ago

christianp commented 4 months ago

e.g. partition(1..5, x, mod(x,2)=0) would return [ [2, 4], [1, 3, 5] ]

christianp commented 4 months ago

This is where we could really do with lambdas. I'm not keen on implementing another 'works like map' function where you give the name(s) to bind as an argument.

christianp commented 1 month ago

This function is now in, called separate(list, condition).