init
This commit is contained in:
commit
1f0a783560
9 changed files with 1045 additions and 0 deletions
41
specification.md
Normal file
41
specification.md
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
```feng
|
||||
how-to mult:
|
||||
requires a number n and a number m
|
||||
resoult is a number
|
||||
1) if m and 0 are equal resoult is 0
|
||||
2) if m and 1 are equal resoult is n
|
||||
3) sub m and 1
|
||||
4) mult n and it
|
||||
5) add n and it // it = resoult of preceding operation
|
||||
6) resoult is it
|
||||
```
|
||||
|
||||
pipeline:
|
||||
lexer -> AST1 -> reverse pass to verify what needs `it` -> code gen
|
||||
|
||||
```haskell
|
||||
mult :: Float -> Float -> Float
|
||||
mult = if mult1 then 0 else if mult2 then n else ((mult3 n m) |> (mult4 n m) |> (mult5 n m))
|
||||
|
||||
mult1 :: Float -> Float -> Bool
|
||||
mult1 n m
|
||||
| m == 0 = True
|
||||
| otherwise = False
|
||||
|
||||
mult2 :: Float -> Float -> Bool
|
||||
mult2 n m
|
||||
| m == 1 = True
|
||||
| otherwise = False
|
||||
|
||||
mult3 :: Float -> Float -> Float
|
||||
mult3 n m = sub m 1
|
||||
|
||||
mult4 :: Float -> Float -> Float -> Float
|
||||
mult4 n m it = mult n it
|
||||
|
||||
mult5 :: Float -> Float -> Float -> Float
|
||||
mult5 n m it = n + it
|
||||
|
||||
mult6 :: Float -> Float -> Float -> Float
|
||||
mult6 n m it = it
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue