Cuihtlauac's Avatar

Cuihtlauac

@cuihtlauac

Corecursive tinkerer, camler, globetrotter

145
Followers
55
Following
12
Posts
18.11.2024
Joined
Posts Following

Latest posts by Cuihtlauac @cuihtlauac

Post image

#ocaml

04.02.2025 16:13 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0

You stand in good company:

Let us change our traditional attitude to the construction of programs. Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.

Donald Knuth, 1992

04.02.2025 06:50 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0

I also like this one:
module String = struct include Stdlib.String module Map = Map.Make(Stdlib.String) end

03.02.2025 19:08 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

Quite an effort indeed, but with a high degree of parallelizability.

28.01.2025 17:06 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

That looks fine. I'm among those who don't use polymorphic variants unless there's a strong case for such as ocaml.org/docs/error-h...

23.01.2025 15:24 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0

Indeed it does. It's >>= fun, which is the same as let*. Custom binder gives you a free (and hidden) eta.

23.01.2025 11:26 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

Yes, it is. But I find it particularly disturbing in that case. We hear >>= and let* are the same. Not in that respect.

23.01.2025 11:02 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0
Video thumbnail
23.01.2025 10:32 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

let ( >>= ) = Lwt.bind
let ( let* ) = Lwt.bind

(* Prints hello after world *)
let _ = f "hello" () >>= f "world"

(* Prints world after hello *)
let _ = let* u = f "hello" () in f "world" u

Can you write f? What's going on?
#ocaml #lwt

23.01.2025 06:36 ๐Ÿ‘ 2 ๐Ÿ” 0 ๐Ÿ’ฌ 2 ๐Ÿ“Œ 0

1: f L gives I. n is a T with holes labelled x or y. 2: chop Is gives H2 hole set. 3&4: chop 2s gives H3 and H4 hole sets. {x} = H2 โˆฉ H3, {y} = H2 โˆฉ H4. Something like that? Haven't written the code. Can you solve that as polynomial coefficients from points?

22.01.2025 14:53 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

#ocaml binding operator abuse

let ( let< ) ic f =
Fun.protect ~finally:(fun () -> In_channel.close ic) (fun () -> f ic)

let () =
let< ic = In_channel.open_text Sys.argv.(1) in
In_channel.input_lines ic
|> List.concat_map (String.split_on_char ' ')
|> List.iter print_string

15.01.2025 10:12 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0

Isn't it Barron and Strachey product? That's far from trivial.

11.01.2025 16:59 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0