Skip to content

Commit

Permalink
Updating std.decimal.
Browse files Browse the repository at this point in the history
  • Loading branch information
bendmorris committed Jul 20, 2011
1 parent cf1c887 commit 3ea22b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Scotch/Eval/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ eval oexp vars settings rw =
EagerDef f x y -> case fullEval x eval' of
Val v -> next
List l -> next
otherwise -> EagerDef f otherwise y
otherwise -> next--EagerDef f otherwise y
where next = evalWithNewDefs y [(f, fullEval x eval')]
If cond x y -> case fullEval cond eval' of
Val (Bit True) -> x
Expand Down
12 changes: 6 additions & 6 deletions scotch.lib/std/decimal.sco
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ read_decimal(h:t, a) = case h of
read_decimal([], a) = Decimal(int(a), 0)
decimal(s) = read_decimal(s, "0")

print(Decimal(a,b)) = print((if l > b then left(s, l - b) else "0") +
"." +
case ("0" * (b - l)) + right(s, b) of
"" -> "0",
otherwise -> otherwise
where s = str(a), l := len(s))
print(Decimal(a,b)) = print(((if l > b then left(s, l - b) else "0") +
"." +
case str([for i in [2..b], "0"]) + str(right(s, b)) of
"" -> "0",
otherwise -> otherwise)
where s = str(a), l := len(s))

float(Decimal(a,b)) = (a * (10 ^ (-b)))

Expand Down
2 changes: 1 addition & 1 deletion scotch.lib/std/lib.sco
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ only([], s) = []
left(h:t, n) = take n from h:t
left(h:t, 0) = []
left([], n) = []
right(h:t, n) = [for i in [l - n .. l - 1], (h:t) @ i] where l := len(h:t)
right(h:t, n) = [for i in [if l > n then (l - n) else 0 .. l - 1], (h:t) @ i] where l := len(h:t)

foldl(f, h:t, z) = foldl(f, t, f(z, h))
foldl(f, [], z) = z
Expand Down

0 comments on commit 3ea22b0

Please sign in to comment.