Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,15 @@
(define (shuffle tp)
(let ((items (vm:cast tp (type tp)))) ; make a copy
(for-each (lambda (i)
(let ((a (ref items i))
(j (+ 1 (rand! i))))
(set-ref! items i (ref items j))
(set-ref! items j a)))
(reverse (iota (size items) 1)))
items))
(define (list-shuffle tp)
(map (lambda (i)
(list-ref tp i))
(tuple->list
(shuffle (list->tuple (iota (length tp)))))))

View file

@ -0,0 +1,7 @@
(define items (tuple 1 2 3 4 5 6 7 8 9))
(print "tuple before: " items)
(print "tuple after: " (shuffle items))
(define items (list 1 2 3 4 5 6 7 8 9))
(print "list before: " items)
(print "list after: " (list-shuffle items))