l-99

solutions to l-99 (slow)
Log | Files | Refs | Feed | README

commit fd6f65d949be7282e9f38e3d51b376b28f2cd816
parent fe0c908ce1f9499d25f2d816d72fa666caeb1ba7
Author: Jenny Doe <tng@soykaf.me>
Date:   Thu,  2 May 2019 14:31:40 +0200

added: p23.scm

Diffstat:
Ap23.scm | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/p23.scm b/p23.scm @@ -0,0 +1,16 @@ +; (**) Extract a given number of randomly selected elements from a list. +; The selected items shall be returned in a list. +; Example: +; * (rnd-select '(a b c d e f g h) 3) +; (E D A) +; +; Hint: Use the built-in random number generator and the result of problem +; P20. + +(load "p03.scm") + +(define (rnd-select ls n) + (if (zero? n) + '() + (cons (element-at ls (random (length ls))) + (rnd-select ls (- n 1)))))