feng/specification.md
2026-02-21 00:51:37 +01:00

41 lines
892 B
Markdown

```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
```