Created
January 10, 2025 21:30
-
-
Save chrisdone-artificial/95964c8d1ee63257edd4ae0d36908aa0 to your computer and use it in GitHub Desktop.
hell vs ghci fib(35)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
20,952,577,648 bytes allocated in the heap | |
5,725,800 bytes copied during GC | |
84,856 bytes maximum residency (2 sample(s)) | |
24,704 bytes maximum slop | |
6 MiB total memory in use (0 MiB lost due to fragmentation) | |
Tot time (elapsed) Avg pause Max pause | |
Gen 0 5009 colls, 0 par 0.046s 0.029s 0.0000s 0.0001s | |
Gen 1 2 colls, 0 par 0.000s 0.000s 0.0001s 0.0001s | |
TASKS: 4 (1 bound, 3 peak workers (3 total), using -N1) | |
SPARKS: 0 (0 converted, 0 overflowed, 0 dud, 0 GC'd, 0 fizzled) | |
INIT time 0.000s ( 0.000s elapsed) | |
MUT time 2.822s ( 2.829s elapsed) | |
GC time 0.046s ( 0.029s elapsed) | |
EXIT time 0.000s ( 0.002s elapsed) | |
Total time 2.868s ( 2.860s elapsed) | |
Alloc rate 7,424,903,353 bytes per MUT second | |
Productivity 98.4% of total user, 98.9% of total elapsed | |
-} | |
main = do | |
Text.putStrLn (Int.show (Main.fib 35)) | |
fib = | |
Function.fix | |
(\fib i -> | |
Bool.bool | |
(Bool.bool | |
(Int.plus (fib (Int.subtract 1 i)) | |
(fib (Int.subtract 2 i))) | |
1 | |
(Int.eq i 1)) | |
0 | |
(Int.eq i 0) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
ghci> main | |
9227465 | |
(7.98 secs, 10,305,414,480 bytes) | |
-} | |
import Data.Function | |
import Data.Bool | |
main = do | |
putStrLn (show (fib 35)) | |
fib :: Int -> Int | |
fib = | |
fix | |
(\fib i -> | |
bool | |
(bool | |
((+) (fib (subtract 1 i)) | |
(fib (subtract 2 i))) | |
1 | |
((==) i 1)) | |
0 | |
((==) i 0) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment