From 1bca8914529b5d535efec1cf773cecf2ee11dd9e Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 30 Apr 2015 15:29:49 +0200 Subject: [PATCH] dynset --- fp2/week3/camil/StdDynSet.dcl | 24 ++ fp2/week3/camil/StdDynSet.icl | 66 ++++ fp2/week3/camil/StdDynSet.prj | 569 ++++++++++++++++++++++++++++++++++ fp2/week3/camil/StdDynSet.prp | 217 +++++++++++++ 4 files changed, 876 insertions(+) create mode 100644 fp2/week3/camil/StdDynSet.dcl create mode 100644 fp2/week3/camil/StdDynSet.icl create mode 100644 fp2/week3/camil/StdDynSet.prj create mode 100644 fp2/week3/camil/StdDynSet.prp diff --git a/fp2/week3/camil/StdDynSet.dcl b/fp2/week3/camil/StdDynSet.dcl new file mode 100644 index 0000000..66964ad --- /dev/null +++ b/fp2/week3/camil/StdDynSet.dcl @@ -0,0 +1,24 @@ +definition module StdDynSet + +import StdOverloaded + +class Set a | TC, ==, toString a + +:: Set + +instance zero Set +instance toString Set +instance == Set + +//toSet :: a -> Set | Set a + +nrOfElts :: Set -> Int +isEmptySet :: Set -> Bool + +//memberOfSet :: a Set -> Bool | Set a +isSubset :: Set Set -> Bool +isStrictSubset :: Set Set -> Bool + +union :: Set Set -> Set +intersection :: Set Set -> Set +without :: Set Set -> Set diff --git a/fp2/week3/camil/StdDynSet.icl b/fp2/week3/camil/StdDynSet.icl new file mode 100644 index 0000000..ef6198d --- /dev/null +++ b/fp2/week3/camil/StdDynSet.icl @@ -0,0 +1,66 @@ +implementation module StdDynSet + +import StdEnv +import StdMaybe +import StdDynamic + +fromDynamic :: Dynamic -> Maybe t | TC t +fromDynamic (x :: t^) = Just x +fromDynamic other = Nothing + +isEqual:: Dynamic t -> Bool | Set t +isEqual (x :: t^) a = x == a +isEqual _ _ = False + +class Set a | TC, ==, toString a + +:: Set = Set [Dynamic] + +instance zero Set +where zero = Set [] + +instance toString Set +where toString (Set a) = abort "toString not implemented" + +instance == Set +where == a b = nrOfElts a == nrOfElts b && isSubset a b + +toSet :: a -> Set | Set, == a +toSet e = Set [dynamic e] + +nrOfElts :: Set -> Int +nrOfElts (Set a) = length a + +isEmptySet :: Set -> Bool +isEmptySet (Set []) = True +isEmptySet _ = False + +memberOfSet :: a Set -> Bool | Set, == a +memberOfSet _ (Set []) = False +memberOfSet x (Set [(y :: a^):xs]) = x == y || memberOfSet x (Set xs) +memberOfSet x (Set [y:xs]) = memberOfSet x (Set xs) + +dynMemberOfSet :: Dynamic Set -> Bool +dynMemberOfSet _ (Set []) = False +dynMemberOfSet x (Set [y:xs]) = isEqual x (fromJust(fromDynamic y)) || dynMemberOfSet x (Set xs) +//dynMemberOfSet x (Set [y:xs]) = memberOfSet x (Set xs) + +isSubset :: Set Set -> Bool +isSubset a b = (nrOfElts a) == (nrOfElts (intersection a b)) + +isStrictSubset :: Set Set -> Bool +isStrictSubset a b = abort "isStrictSubset nog niet geimplementeerd.\n" + +union :: Set Set -> Set +union (Set a) (Set b) = Set (a ++ b) + +intersection :: Set Set -> Set +intersection (Set []) bs = bs +intersection as (Set []) = as +intersection (Set [a:as]) (Set [(b::t):bs]) = Set [a \\ a <- as | not (dynMemberOfSet a (Set bs))] + +without :: Set Set -> Set +without a b = abort "without nog niet geimplementeerd.\n" + +//Start :: Set +Start = memberOfSet 2 (toSet 1) diff --git a/fp2/week3/camil/StdDynSet.prj b/fp2/week3/camil/StdDynSet.prj new file mode 100644 index 0000000..acd7e19 --- /dev/null +++ b/fp2/week3/camil/StdDynSet.prj @@ -0,0 +1,569 @@ +Version: 1.4 +Global + ProjectRoot: . + Built: True + Target: Experimental + Exec: {Project}\StdDynSet.exe + CodeGen + CheckStacks: False + CheckIndexes: True + Application + HeapSize: 2097152 + StackSize: 512000 + ExtraMemory: 81920 + IntialHeapSize: 204800 + HeapSizeMultiplier: 4096 + ShowExecutionTime: False + ShowGC: False + ShowStackSize: False + MarkingCollector: False + StandardRuntimeEnv: True + Profile + Memory: False + MemoryMinimumHeapSize: 0 + Time: False + Stack: False + Output + Output: ShowConstructors + Font: Courier + FontSize: 9 + WriteStdErr: False + Link + LinkMethod: Static + GenerateRelocations: False + GenerateLinkMap: False + LinkResources: False + ResourceSource: + GenerateDLL: False + ExportedNames: + Paths + Path: {Project} + Precompile: + Postlink: +MainModule + Name: StdDynSet + Dir: {Project} + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False +OtherModules + Module + Name: StdCleanTypes + Dir: {Application}\Libraries\Dynamics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdDynamic + Dir: {Application}\Libraries\Dynamics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: BitSet + Dir: {Application}\Libraries\Dynamics\general + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: DefaultElem + Dir: {Application}\Libraries\Dynamics\general + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: EnDecode + Dir: {Application}\Libraries\Dynamics\general + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: DynIDMacros + Dir: {Application}\Libraries\Dynamics\implementation + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: DynamicUtilities + Dir: {Application}\Libraries\Dynamics\implementation + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdDynamicLowLevelInterface + Dir: {Application}\Libraries\Dynamics\implementation + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdDynamicTypes + Dir: {Application}\Libraries\Dynamics\implementation + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdDynamicVersion + Dir: {Application}\Libraries\Dynamics\implementation + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: _SystemDynamic + Dir: {Application}\Libraries\Dynamics\implementation + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: DynamicGraphConversion + Dir: {Application}\Libraries\Dynamics\implementation\windows + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: DynamicLinkerInterface + Dir: {Application}\Libraries\Dynamics\implementation\windows + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + NeededObjFiles + ObjectFile: read_function.obj + Module + Name: memory + Dir: {Application}\Libraries\Dynamics\implementation\windows + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + NeededObjFiles + ObjectFile: mem.obj + Module + Name: memory_mapped_files + Dir: {Application}\Libraries\Dynamics\implementation\windows + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + NeededObjFiles + ObjectFile: low.obj + NeededLibraries + Library: StdDynamic_kernel32_library + Module + Name: shared_buffer + Dir: {Application}\Libraries\Dynamics\implementation\windows + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdArray + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdBool + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdChar + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdCharList + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdClass + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdEnum + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdEnv + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdFile + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdFunc + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdInt + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdList + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdMisc + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdOrdList + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdOverloaded + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdReal + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdString + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdTuple + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: _SystemArray + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: _SystemEnum + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdMaybe + Dir: {Application}\Libraries\StdLib + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False diff --git a/fp2/week3/camil/StdDynSet.prp b/fp2/week3/camil/StdDynSet.prp new file mode 100644 index 0000000..ed13257 --- /dev/null +++ b/fp2/week3/camil/StdDynSet.prp @@ -0,0 +1,217 @@ +Version: 1.4 +MainModule + Name: StdDynSet + Dir: {Project} + Dcl + WindowPosition + X: 65 + Y: 47 + SizeX: 800 + SizeY: 640 + DclOpen: False + Icl + WindowPosition + X: 10 + Y: 10 + SizeX: 800 + SizeY: 600 + IclOpen: False +OtherModules + Module + Name: StdCleanTypes + Dir: {Application}\Libraries\Dynamics + Dcl + WindowPosition + X: 10 + Y: 10 + SizeX: 800 + SizeY: 600 + DclOpen: False + IclOpen: False + Module + Name: StdDynamic + Dir: {Application}\Libraries\Dynamics + Dcl + WindowPosition + X: 276 + Y: 168 + SizeX: 800 + SizeY: 600 + DclOpen: False + IclOpen: False + Module + Name: BitSet + Dir: {Application}\Libraries\Dynamics\general + DclOpen: False + IclOpen: False + Module + Name: DefaultElem + Dir: {Application}\Libraries\Dynamics\general + DclOpen: False + IclOpen: False + Module + Name: EnDecode + Dir: {Application}\Libraries\Dynamics\general + DclOpen: False + IclOpen: False + Module + Name: DynIDMacros + Dir: {Application}\Libraries\Dynamics\implementation + DclOpen: False + IclOpen: False + Module + Name: DynamicUtilities + Dir: {Application}\Libraries\Dynamics\implementation + DclOpen: False + IclOpen: False + Module + Name: StdDynamicLowLevelInterface + Dir: {Application}\Libraries\Dynamics\implementation + DclOpen: False + IclOpen: False + Module + Name: StdDynamicTypes + Dir: {Application}\Libraries\Dynamics\implementation + DclOpen: False + IclOpen: False + Module + Name: StdDynamicVersion + Dir: {Application}\Libraries\Dynamics\implementation + DclOpen: False + IclOpen: False + Module + Name: _SystemDynamic + Dir: {Application}\Libraries\Dynamics\implementation + DclOpen: False + IclOpen: False + Module + Name: DynamicGraphConversion + Dir: {Application}\Libraries\Dynamics\implementation\windows + DclOpen: False + IclOpen: False + Module + Name: DynamicLinkerInterface + Dir: {Application}\Libraries\Dynamics\implementation\windows + DclOpen: False + IclOpen: False + Module + Name: memory + Dir: {Application}\Libraries\Dynamics\implementation\windows + DclOpen: False + IclOpen: False + Module + Name: memory_mapped_files + Dir: {Application}\Libraries\Dynamics\implementation\windows + DclOpen: False + IclOpen: False + Module + Name: shared_buffer + Dir: {Application}\Libraries\Dynamics\implementation\windows + DclOpen: False + IclOpen: False + Module + Name: StdArray + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdBool + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdChar + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdCharList + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdClass + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdEnum + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdEnv + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdFile + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdFunc + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdInt + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdList + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdMisc + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdOrdList + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdOverloaded + Dir: {Application}\Libraries\StdEnv + Dcl + WindowPosition + X: 10 + Y: 10 + SizeX: 800 + SizeY: 600 + DclOpen: False + IclOpen: False + Module + Name: StdReal + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdString + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdTuple + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: _SystemArray + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: _SystemEnum + Dir: {Application}\Libraries\StdEnv + DclOpen: False + IclOpen: False + Module + Name: StdMaybe + Dir: {Application}\Libraries\StdLib + DclOpen: False + IclOpen: False -- 2.20.1