Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 36s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
62 lines
1.7 KiB
Plaintext
62 lines
1.7 KiB
Plaintext
;; setops.hs — set union/intersection/difference on integer sets.
|
|
;;
|
|
;; Exercises Phase 12: `import qualified Data.Set as Set`, all three
|
|
;; combining operations + isSubsetOf.
|
|
|
|
(define
|
|
hk-setops-source
|
|
"import qualified Data.Set as Set\n\ns1 = Set.insert 1 (Set.insert 2 (Set.insert 3 Set.empty))\ns2 = Set.insert 3 (Set.insert 4 (Set.insert 5 Set.empty))\ns3 = Set.insert 1 (Set.insert 2 Set.empty)\n")
|
|
|
|
(hk-test
|
|
"setops.hs — union size = 5"
|
|
(hk-deep-force
|
|
(hk-run (str hk-setops-source "main = Set.size (Set.union s1 s2)\n")))
|
|
5)
|
|
|
|
(hk-test
|
|
"setops.hs — intersection size = 1"
|
|
(hk-deep-force
|
|
(hk-run
|
|
(str hk-setops-source "main = Set.size (Set.intersection s1 s2)\n")))
|
|
1)
|
|
|
|
(hk-test
|
|
"setops.hs — intersection contains 3"
|
|
(hk-deep-force
|
|
(hk-run
|
|
(str hk-setops-source "main = Set.member 3 (Set.intersection s1 s2)\n")))
|
|
(list "True"))
|
|
|
|
(hk-test
|
|
"setops.hs — difference s1 s2 size = 2"
|
|
(hk-deep-force
|
|
(hk-run (str hk-setops-source "main = Set.size (Set.difference s1 s2)\n")))
|
|
2)
|
|
|
|
(hk-test
|
|
"setops.hs — difference doesn't contain shared key"
|
|
(hk-deep-force
|
|
(hk-run
|
|
(str hk-setops-source "main = Set.member 3 (Set.difference s1 s2)\n")))
|
|
(list "False"))
|
|
|
|
(hk-test
|
|
"setops.hs — s3 is subset of s1"
|
|
(hk-deep-force
|
|
(hk-run (str hk-setops-source "main = Set.isSubsetOf s3 s1\n")))
|
|
(list "True"))
|
|
|
|
(hk-test
|
|
"setops.hs — s1 not subset of s3"
|
|
(hk-deep-force
|
|
(hk-run (str hk-setops-source "main = Set.isSubsetOf s1 s3\n")))
|
|
(list "False"))
|
|
|
|
(hk-test
|
|
"setops.hs — empty set is subset of anything"
|
|
(hk-deep-force
|
|
(hk-run (str hk-setops-source "main = Set.isSubsetOf Set.empty s1\n")))
|
|
(list "True"))
|
|
|
|
{:fails hk-test-fails :pass hk-test-pass :fail hk-test-fail}
|