Racket, split a list in two different size lists. And randomly
问题 I would like to code a program that given a list and a percentage, splits the list in two different size lists. It should have random pick of the elements, that way the created lists are always different. These code is able to do that: (define (clamp x a b) (max (min x b) a)) (define (split pct xs) (define pos (exact-round (* (clamp pct 0.0 1.0) (length xs)))) (split-at (shuffle xs) pos)) Here is an example: (split 0.25 '(1 2 3 4 5 6 7 8 9)) '(6 2) '(3 7 1 4 5 8 9) But, instead of "shuffle" I