Skip to content

Instantly share code, notes, and snippets.

@AHaliq
AHaliq / euclid.hs
Created August 13, 2021 10:14
Haskell Euclid Algorithm
euclid :: Integer -> Integer -> Integer
euclid a b = case aux a b 0 of
0 -> b
r -> euclid b r
where
aux a b q = if b >= a then b - a else aux (a-b) b (q+1)
-- get gcd
main = do
a <- readLn :: IO Integer
@AHaliq
AHaliq / config.log
Created August 24, 2021 02:33
WASI Output
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by GNU MP configure 6.2.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure --prefix /Users/haliq/opt-wasm CC=/opt/wasi-sdk-12.0/bin/clang --host=none --enable-cxx CXX=/opt/wasi-sdk-12.0/bin/clang++ --with-sysroot=/opt/wasi-sysroot
## --------- ##
## Platform. ##
@AHaliq
AHaliq / kaprekar.hs
Created April 29, 2022 15:37
Kaprekar's constant
import Data.List
toDigits x
| x > 9 = x `mod` 10 : toDigits (x `div` 10)
| otherwise = [x]
sumFold xs = foldl (\a x -> a*10 + x) 0 xs
kaprekar :: Int -> Int -> Int
kaprekar x n = let