Search Results

Found 1 results for "d6558f6f140c09a03e3b104de49ac6fc" across all boards searching md5.

Anonymous /g/105527756#105566765
6/12/2025, 3:24:44 AM
>>105546941
Ok I've tried Roc:
- The standard library is so little (no string->chars have to walk over the u8s and pray)
- Performance is giga fast
- Half the time spent is appeasing the compiler
- Result type like rust but no unwrap only defaults???
- Doesnt suffer from cold boot like Racket compiled 200ms on day1 aoc 2024 EXAMPLE vs 1ms full day1 part 1 with text parsing in Roc

I feel compelled to create a library of utility functions, maybe Roc anons can recommend some if they exists already? Wherever I looked so far everyone has their own flat_map, fold, reduce etc in their utils.

app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br" }

import pf.Stdout

import "day1.txt" as day1: Str

# example = "3 4\n4 3\n2 5\n1 3\n3 9\n3 3\n"

parse = |s|
s
|> Str.split_on("\n")
|> List.map
|v|
v
|> Str.split_on " "
|> List.map |x| Str.to_u64(x) ?? 0
|> List.drop_last 1
|> List.walk
([], [])
|(left, right), v|
when v is
[a, b] -> (List.append left a, List.append right b)
_ -> (left, right)
# |> dbg

main! = |_|
# _ : List (List _)
total =
# parse example
parse day1
|> |(l, r)| (List.sort_asc l, List.sort_asc r)
|> |(l, r)| List.map2 l r Num.abs_diff
|> List.sum
# |> dbg

Stdout.write! "${Inspect.to_str total}"