Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Tweak prime-sieve.ss; add powerset.rkt

  • Loading branch information...
commit 7b3d9a901c56e1b18ddfd1d6e50137af0baa83b1 1 parent c6e308d
Eric Hanchrow authored

Showing 2 changed files with 20 additions and 1 deletion. Show diff stats Hide diff stats

  1. +19 0 powerset.rkt
  2. +1 1  prime-sieve.ss
19 powerset.rkt
... ... @@ -0,0 +1,19 @@
  1 +#lang racket
  2 +
  3 +(define (with-extra item seqs)
  4 + (apply set
  5 + (set-map seqs
  6 + (lambda (s)
  7 + (set-add s item)))))
  8 +
  9 +(define (powerset seq)
  10 + (cond
  11 + ((null? seq)
  12 + (set))
  13 + ((null? (cdr seq))
  14 + (set (set) (set (car seq))))
  15 + (else
  16 + (set-union
  17 + (powerset (cdr seq))
  18 + (with-extra (car seq)
  19 + (powerset (cdr seq)))))))
2  prime-sieve.ss
@@ -10,7 +10,7 @@ exec mzscheme -l errortrace --require "$0" --main -- ${1+"$@"}
10 10 #lang scheme
11 11
12 12 ;; Crude copy of the "go" language's "go" statement.
13   -(define-syntax-rule (go body ...) (begin (thread (lambda () body ...)) (void)))
  13 +(define-syntax-rule (go body ...) (begin (thread (thunk body ...)) (void)))
14 14
15 15 ;; Send the sequence 2, 3, 4, ... to channel 'ch'.
16 16 (define (generate ch)

0 comments on commit 7b3d9a9

Please sign in to comment.
Something went wrong with that request. Please try again.