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,4 @@
(define (subsets l)
(if (null? l) '(())
(append (for/list ([l2 (subsets (cdr l))]) (cons (car l) l2))
(subsets (cdr l)))))

View file

@ -0,0 +1,9 @@
#lang racket
(define (non-continuous-subseqs l)
(let loop ([l l] [x 0])
(if (null? l) (if (>= x 3) '(()) '())
(append (for/list ([l2 (loop (cdr l) (if (even? x) (add1 x) x))])
(cons (car l) l2))
(loop (cdr l) (if (odd? x) (add1 x) x))))))
(non-continuous-subseqs '(1 2 3 4))
;; => '((1 2 4) (1 3 4) (1 3) (1 4) (2 4))