Skip to content
This repository was archived by the owner on Oct 12, 2026. It is now read-only.

Commit 879cd09

Browse files
committed
Update emacs major mode for Lambda Discipline, New example examples/aoc-24/day-01/part_02.lbd
1 parent 9bd82ae commit 879cd09

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

‎editor-plugins/emacs/lbd-mode.el‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@
3131
"Syntax table for lbd-mode.")
3232

3333
;; Comment settings
34-
(setq-local comment-start "-- ")
34+
(setq-local comment-start "--")
3535
(setq-local comment-end "")
3636

3737
;; Font lock
3838
(defconst lbd--keywords
39-
'("true" "false" "if_then" "pair" "first" "second" "use")
39+
'("true" "false" "if_then" "pair" "first" "second" "use"
40+
"print" "add" "sub" "mul" "cmp" "if_zero" "sort" "parse_float"
41+
"list" "list_size" "list_get" "list_remove" "list_append" "map" "transpose" "zip" "foldr"
42+
"slurp_file" "lines" "split")
4043
"Language keywords for lbd-mode.")
4144

4245
(defvar lbd-font-lock-keywords

‎examples/aoc-24/day-01/part_02.lbd‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
-- Problem Link: <https://adventofcode.com/2024/day/1>
2+
3+
-- TODO: This is super slow, optimize this
4+
5+
use "examples/std.lbd"
6+
7+
content: String = (slurp_file "examples/aoc-24/day-01/input.txt")
8+
entries: List = (lines content)
9+
10+
tmp: String -> Any = \x: String. (rot_2 split " " x)
11+
cols: List = (transpose (map tmp entries))
12+
13+
tmp2: List -> Any = \x: List. (map parse_float x)
14+
lists: List = (map tmp2 cols)
15+
16+
eq2: Float -> Float -> Float = \x: Float. \y: Float. (if_then (eq y x) 1 0)
17+
add2: Float -> Float -> Float = \x: Float. \y: Float. (add y x)
18+
19+
count: List -> Any -> Float = \xs: List. \x: Any. (foldr add2 0 (map (eq2 x) xs))
20+
21+
l0: List = (list_get lists 0)
22+
l1: List = (list_get lists 1)
23+
24+
tmp3: List -> Float = \xs: List. (mul (list_get xs 0) (list_get xs 1))
25+
26+
(print "Answer: " (foldr add2 0 (map tmp3 (zip (list l0 (map (count l1) l0))))) "\n")

0 commit comments

Comments
 (0)