aoc-util.utils

Helper functions

-numbersFromStr

(-numbersFromStr s)

-strInt

(-strInt s)

define

macro

(define name bindings lambda-bindings & body)

Inspired from scheme to shortcut functions which return a lambda function

(define f [a] [b] (+ a b))

((f 5) 3) ;;=> 8

dijkstra

(dijkstra g start)

Computes single-source shortest path distances in a directed graph.

Given a node n, (f n), e.g. MAP, should return a map with the successors of n as keys and their (non-negative) distance from n as vals.

Returns a map from nodes to their distance from start.

dijkstra-seq

(dijkstra-seq g start)

line-process

(line-process input)(line-process input parser-xf)

Process a string line by line takes a parser fn (transducer) which is used with mapv, not lazy

numbers-from-str

(numbers-from-str str)

Retrieves all numbers from a string returns a list of numbers

parse-int

(parse-int s)

Takes a string and tries to parse into an Integer, otherwise nil

save

macro

(save & body)

Executes a body, if an excetption throws, catch and print stacktrace to *err* but returns nil

shortest-path

(shortest-path g start dest)

transpose

(transpose m)

vec-remove

(vec-remove coll pos)

remove elem in coll, returns a subvector