summaryrefslogtreecommitdiff
path: root/Jennisys/Utils.fs
diff options
context:
space:
mode:
authorGravatar Unknown <t-alekm@A3479878.redmond.corp.microsoft.com>2011-07-06 19:56:38 -0700
committerGravatar Unknown <t-alekm@A3479878.redmond.corp.microsoft.com>2011-07-06 19:56:38 -0700
commit87e454054629237ce9b2dcf2a31de059bbda1749 (patch)
treed60355863533d17871e79c7d9bffd404e98cd5a1 /Jennisys/Utils.fs
parent0d74db68e2fffc71f2c66de47b8d5acf89cbad6b (diff)
- fixed some bugs with applying unification over list elements
- fixed the List.jen example (generic list) - changed SeqConst and SetConst to contain a list/set of "Const" and not "Const option" like before
Diffstat (limited to 'Jennisys/Utils.fs')
-rw-r--r--Jennisys/Utils.fs26
1 files changed, 21 insertions, 5 deletions
diff --git a/Jennisys/Utils.fs b/Jennisys/Utils.fs
index 3cb8fee4..6540173c 100644
--- a/Jennisys/Utils.fs
+++ b/Jennisys/Utils.fs
@@ -77,17 +77,17 @@ let SetToOption set =
else
Some(set |> Set.toList |> List.head)
-// ===============================================================
+// ============================================================
/// requires: n >= 0
-/// ensures: |ret| = n && forall i :: 0 <= i < n ==> ret[i] = None
-// ===============================================================
-let rec GenList n =
+/// ensures: |ret| = n && forall i :: 0 <= i < n ==> ret[i] = e
+// ============================================================
+let rec GenList n e =
if n < 0 then
failwith "n must be positive"
if n = 0 then
[]
else
- None :: (GenList (n-1))
+ e :: (GenList (n-1) e)
// ==========================
/// ensures: ret = elem in lst
@@ -171,3 +171,19 @@ let (|Exact|_|) (p:string) (s:string) =
else
None
+// -------------------------------------------
+// ----------------- random ------------------
+// -------------------------------------------
+
+let IfDo1 cond func1 a =
+ if cond then
+ func1 a
+ else
+ a
+
+let IfDo2 cond func2 (a1,a2) =
+ if cond then
+ func2 a1 a2
+ else
+ a1,a2
+