mirror of
https://github.com/chrisdone/duet.git
synced 2025-01-08 06:53:22 +03:00
Fix arg
This commit is contained in:
parent
9b776ff39b
commit
6f23223717
21
README.md
21
README.md
@ -20,3 +20,24 @@ Available options:
|
||||
Available commands:
|
||||
run Run the given program source
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
integers.hs:
|
||||
```haskell
|
||||
main = 3 + ((2 + -3) - 3)
|
||||
```
|
||||
|
||||
Output for this program:
|
||||
|
||||
``` haskell
|
||||
$ duet run examples/integers.hs
|
||||
[1]
|
||||
3 + ((2 + -3) - 3)
|
||||
[2]
|
||||
3 + (-1 - 3)
|
||||
[3]
|
||||
3 + -4
|
||||
[4]
|
||||
-1
|
||||
```
|
||||
|
@ -39,7 +39,7 @@ main = do
|
||||
(Run <$>
|
||||
strArgument (metavar "FILEPATH" <> help "The .hs file to interpret") <*>
|
||||
strOption
|
||||
(long "--main" <> metavar "NAME" <> help "The main value to run" <>
|
||||
(long "main" <> metavar "NAME" <> help "The main value to run" <>
|
||||
value "main") <*>
|
||||
option
|
||||
auto
|
||||
|
@ -1,13 +1,14 @@
|
||||
go = \n res ->
|
||||
case n of
|
||||
0 -> 1
|
||||
n -> go (n - 1) (res * n)
|
||||
factorial = \n -> case n of
|
||||
0 -> 1
|
||||
1 -> 1
|
||||
_ -> n * factorial (n - 1)
|
||||
|
||||
fac = \n -> go n 1
|
||||
|
||||
factorial = \n ->
|
||||
case n of
|
||||
0 -> 1
|
||||
n -> n * factorial (n - 1)
|
||||
go =
|
||||
\n acc ->
|
||||
case n of
|
||||
0 -> 1
|
||||
1 -> 1
|
||||
_ -> go (n - 1) (n * acc)
|
||||
|
||||
main = fac 5
|
||||
it = go 5 1
|
||||
|
Loading…
Reference in New Issue
Block a user