Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/Set-consolidation/Racket/set-consolidation-1.rkt
Normal file
14
Task/Set-consolidation/Racket/set-consolidation-1.rkt
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#lang racket
|
||||
(define (consolidate ss)
|
||||
(define (comb s cs)
|
||||
(cond [(set-empty? s) cs]
|
||||
[(empty? cs) (list s)]
|
||||
[(set-empty? (set-intersect s (first cs)))
|
||||
(cons (first cs) (comb s (rest cs)))]
|
||||
[(consolidate (cons (set-union s (first cs)) (rest cs)))]))
|
||||
(foldl comb '() ss))
|
||||
|
||||
(consolidate (list (set 'a 'b) (set 'c 'd)))
|
||||
(consolidate (list (set 'a 'b) (set 'b 'c)))
|
||||
(consolidate (list (set 'a 'b) (set 'c 'd) (set 'd 'b)))
|
||||
(consolidate (list (set 'h 'i 'k) (set 'a 'b) (set 'c 'd) (set 'd 'b) (set 'f 'g 'h)))
|
||||
4
Task/Set-consolidation/Racket/set-consolidation-2.rkt
Normal file
4
Task/Set-consolidation/Racket/set-consolidation-2.rkt
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(list (set 'b 'a) (set 'd 'c))
|
||||
(list (set 'a 'b 'c))
|
||||
(list (set 'a 'b 'd 'c))
|
||||
(list (set 'g 'h 'k 'i 'f) (set 'a 'b 'd 'c))
|
||||
Loading…
Add table
Add a link
Reference in a new issue