This file contains 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
let reinterpret_float (f : float) : int64 = Obj.( | |
let i = repr 0L | |
and f = repr f | |
in | |
set_field i 1 (field f 0); | |
obj i | |
) | |
let reinterpret_float = Int64.bits_of_float |
This file contains 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
#define wwx ____"" | |
#include /**/<stdio.h> | |
int p ( int ch){ | |
printf ("%c" | |
,ch); } int | |
main() | |
{ char | |
h [] = | |
"hel"\ |
This file contains 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
/* | |
Today it was asked on discord whether Haskell's typeclasses and Rust's traits are equivalent. | |
The answer came from a Haskeller that: | |
> Yes, they’re along the same lines. | |
> Haskell’s typeclasses are more powerful than Rust’s traits though | |
I found that claim a little dubious so I asked them to elaborate.. How are traits less powerful? | |
To which a friend of mine suggested, maybe because Rust doesn't offer functional dependencies. | |
I didn't see why they can't be emulated with existent features. So I replied with that, |
This file contains 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
#!/usr/bin/es | |
tests = ( | |
\e[1mbold\e[0m | |
\e[2mdimmed\e[0m | |
\e[3mitalic\e[0m | |
\e[4munderlined\e[0m | |
\e[5mslowblink\e[0m | |
\e[6mrapidblink\e[0m | |
\e[7minverted\e[0m |
This file contains 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
zipper xs = ([], xs) | |
next (xs, y:ys) = (y:xs, ys) | |
next z = z | |
rmj n = take n naive | |
where | |
naive = go $ zipper [ x^3 + y^3 | x <- [1..], y <- [1..x] ] | |
go (_,[]) = [] | |
go xs@(l,n:_) = let ns = go $ next xs in |
This file contains 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
-- list derivation | |
-- data [a] = [] | a : [a] | |
{- | |
l = 1 + a ⋅ l | |
l - a ⋅ l = 1 | |
l (1 - a) = 1 | |
l = (1 - a)⁻¹ | |
∂l = -1 ⋅ -(1 - a)⁻² |
This file contains 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
(* | |
nat(z). | |
nat(s(N)) :- nat(N). | |
plus(N, z, N). | |
plus(N, s(M), s(A)) :- plus(N, M, A). | |
mult(_, z, z). | |
mult(N, s(M), B) :- mult(N, M, A), plus(N, A, B). |
This file contains 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
{-# OPTIONS_FRONTEND -Wno-overlapping #-} | |
import AllSolutions | |
insert :: a -> [a] -> [a] -- warning: overlapping patterns = ndet | |
insert x xs = x : xs | |
insert x (y:ys) = y : insert x ys | |
perm :: [a] -> [a] | |
perm [] = [] |
This file contains 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
#define show(fmt, ...) (printf("%s: ", #__VA_ARGS__), printf(fmt, __VA_ARGS__)) | |
#define show8(x) printf(#x":\t%02hhx (%hhd)\n", x, x) |
This file contains 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
-- possibly the worst implementation out there but | |
combinations [] = [] | |
combinations xs = go (length xs) (map pure xs) xs where | |
go 1 zs __ = zs | |
go n zs ys = [ y:z | y <- ys, z <- go (n-1) zs ys ] |
NewerOlder