l-99

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

commit 1a856bc72749c4f80a3c791810d1a0d5de4abbce
parent fd6f65d949be7282e9f38e3d51b376b28f2cd816
Author: Jenny Doe <tng@soykaf.me>
Date:   Sun, 12 May 2019 20:08:04 +0200

fixed: p03.scm p23.scm

Diffstat:
Mp03.scm | 2+-
Mp23.scm | 6++++--
2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/p03.scm b/p03.scm @@ -5,6 +5,6 @@ ; C (define (element-at ls n) ; (assert (< n (length ls))) - (if (zero? n) + (if (= 1 n) (car ls) (element-at (cdr ls) (- n 1)))) diff --git a/p23.scm b/p23.scm @@ -8,9 +8,11 @@ ; P20. (load "p03.scm") +(load "p20.scm") (define (rnd-select ls n) (if (zero? n) '() - (cons (element-at ls (random (length ls))) - (rnd-select ls (- n 1))))) + (let ((r (+ 1 (random (length ls))))) + (cons (element-at ls r) + (rnd-select (remove-at ls r) (- n 1))))))