• Andy@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    1 year ago

    I would have liked to see a nice clear example at the top to help me decide if I really want to read about the language.


    EDIT: First sample:

    day := 1;
    import "advent-prelude.noul";
    
    puzzle_input := advent_input();
    
    submit! 1, puzzle_input split "\n\n" map ints map sum then max;
    submit! 2, puzzle_input split "\n\n" map ints map sum then sort then (_[-3:]) then sum;
    

    Looks not too different from what you might do in Factor:

    : totals ( -- seq )
      puzzle-input "\n\n" split-subseq [ split-lines [ string>number ] map-sum ] map
    ;
    
    : part1 ( -- ) totals supremum . ;
    
    : part2 ( -- ) totals sort 3 tail* sum . ;