Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tweak prime-sieve.ss; add powerset.rkt

  • Loading branch information...
commit 7b3d9a901c56e1b18ddfd1d6e50137af0baa83b1 1 parent c6e308d
Eric Hanchrow authored
Showing with 20 additions and 1 deletion.
  1. +19 −0 powerset.rkt
  2. +1 −1  prime-sieve.ss
19 powerset.rkt
View
@@ -0,0 +1,19 @@
+#lang racket
+
+(define (with-extra item seqs)
+ (apply set
+ (set-map seqs
+ (lambda (s)
+ (set-add s item)))))
+
+(define (powerset seq)
+ (cond
+ ((null? seq)
+ (set))
+ ((null? (cdr seq))
+ (set (set) (set (car seq))))
+ (else
+ (set-union
+ (powerset (cdr seq))
+ (with-extra (car seq)
+ (powerset (cdr seq)))))))
2  prime-sieve.ss
View
@@ -10,7 +10,7 @@ exec mzscheme -l errortrace --require "$0" --main -- ${1+"$@"}
#lang scheme
;; Crude copy of the "go" language's "go" statement.
-(define-syntax-rule (go body ...) (begin (thread (lambda () body ...)) (void)))
+(define-syntax-rule (go body ...) (begin (thread (thunk body ...)) (void)))
;; Send the sequence 2, 3, 4, ... to channel 'ch'.
(define (generate ch)
Please sign in to comment.
Something went wrong with that request. Please try again.