Snippets created by Bjørn Bæverfjord

  • Largest palindrome made from the product of two n-digit numbers

    A generalised version of the solution to the fourth Project Euler problem - Largest palindrome product, using sequences. The key to understanding this code is how " (fun x -> ( (fun y -> x * y) baseSeq)) baseSeq" generates a sequence of sequences that contains the products of all possible combinations of two n-digit numbers. " (fun x -> ( (fun y -> x * y) {1..3})) {1..3}" will generate: seq [seq [1; 2; 3]; seq [2; 4; 6]; seq [3; 6; 9]]

    0 people like this

    Posted: 4 years ago by Bjørn Bæverfjord

  • Count leading zeros

    Several ways of counting leading zeros in a binary number. Update: clzDeBruijn now captures the look-up table in the closure so that the table is only evaluated once and everything is contained in the main function.

    3 people like this

    Posted: 3 years ago by Bjørn Bæverfjord

  • Optimal bitwise CIL-like code optimizer

    Prototype of a CIL code optimizer that generates optimal code for bitwise functions. Update: General improvements

    2 people like this

    Posted: 2 years ago by Bjørn Bæverfjord