Add README
parent
85cf2e5a3a
commit
96231739b3
|
@ -0,0 +1,66 @@
|
||||||
|
# [The Universal Calculator](https://git.ewanick.com/bill/universal-calculator)
|
||||||
|
|
||||||
|
Using the GHC REPL and Haskell to teach programming concepts through the guise of mathematics.
|
||||||
|
A handy assistant to help you understand and solve maths problems.
|
||||||
|
|
||||||
|
- GHC = [Glasgow Haskell Compiler](https://www.haskell.org/ghc/)
|
||||||
|
- REPL = [Read Evaluate Print Loop](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)
|
||||||
|
- Haskell = [Lazy, Pure, Functional Programming Language](https://www.haskell.org/)
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
|
||||||
|
```Haskell
|
||||||
|
λ> 5 * 5
|
||||||
|
25
|
||||||
|
|
||||||
|
λ> 1 + 5
|
||||||
|
6
|
||||||
|
|
||||||
|
λ> 10 / 2
|
||||||
|
5.0
|
||||||
|
|
||||||
|
λ> 10 `div` 2
|
||||||
|
5
|
||||||
|
|
||||||
|
λ> 10 `div` 3
|
||||||
|
3
|
||||||
|
|
||||||
|
λ> 10 / 3
|
||||||
|
3.3333333333333335
|
||||||
|
|
||||||
|
λ> :t sum
|
||||||
|
sum :: (Foldable t, Num a) => t a -> a
|
||||||
|
|
||||||
|
λ> :t sum [1..100]
|
||||||
|
sum [1..100] :: (Num a, Enum a) => a
|
||||||
|
|
||||||
|
λ> sum [1..100]
|
||||||
|
5050
|
||||||
|
|
||||||
|
λ> f x = 5*x^3 + 4*x + 2
|
||||||
|
|
||||||
|
λ> f 1
|
||||||
|
11
|
||||||
|
|
||||||
|
λ> f 10
|
||||||
|
5042
|
||||||
|
|
||||||
|
λ> f 100
|
||||||
|
5000402
|
||||||
|
|
||||||
|
λ> map f [1..10]
|
||||||
|
[11,50,149,338,647,1106,1745,2594,3683,5042]
|
||||||
|
|
||||||
|
λ> putStrLn "Hello, world!"
|
||||||
|
Hello, world!
|
||||||
|
```
|
||||||
|
|
||||||
|
## How to install
|
||||||
|
|
||||||
|
- Use the DeterminateSystems installer to install Nix with Flakes.
|
||||||
|
- <https://github.com/DeterminateSystems/nix-installer>
|
||||||
|
- `cd` into the top level of this repo.
|
||||||
|
- `nix develop` and let Nix load the flake and set everything up.
|
||||||
|
- `ghci` and get computing!
|
||||||
|
- To disable performance timings after every input, type `λ> :unset +s` in the REPL
|
||||||
|
- See other initial commands being run in the `.ghci` file.
|
Loading…
Reference in New Issue