Simple functional Python library designed for learning and problem solving purposes inspired by APL and Elixir programming languages.
Created mainly for solving Advent of Code challenges - hence the name advent.
While Python is a very versatile and powerful programming language it lacks functional approach found in other languages.
For better demonstration let's look at the puzzle Calorie Counting from day 1 of Advent of Code 2022.
with open('input.txt') as file:
content = file.read()
biggest = 0
for chunk in content.split('\n\n'):
total = 0
for line in chunk.split('\n'):
n = int(line)
total += n
if total > biggest:
biggest = total
print(biggest)with open('input.txt') as file:
content = file.read()
parsed = (map(int, line.split('\n')) for line in content.split('\n\n'))
solution = max(map(sum, parsed))
print(solution)from advent import *
solve = gen.read_file('input.txt') | txt.split_by('\n\n') | al.map(txt.split_by('\n') | al.map(int) | al.sum()) | al.max()
print(solve())File.read!("input.txt")
|> String.split("\n\n")
|> Stream.map(fn line ->
line
|> String.split("\n")
|> Stream.map(&String.to_integer/1)
|> Enum.sum()
end)xD
|> Enum.max()
|> IO.puts()- algorithms (al)
- combinators (cb)
- functions (fun)
- generators (gen)
- operators (op)
- regex (rgx)
- textual (txt)
- Clean interface (arguably)
- Functions piping
- Arguments binding
- Basic combinators