I’m a “Neovim Refugee” trying to get a deeper/better understanding of how emacs lisp works and how i can use it to expand on my emacs setup. I have never done anything in lisp before and still struggle to understand how single quotes signify a function or what ever.

With that said, i was also planning on doing AoC this year. Originally i wanted to look into zig or go, but now think that this might be the opportunity to dive into lisp for a bit.

But with knowing basically nothing: Is this even “viable”, or advisable? Should i be looking at common lisp instead? Or would you say that’s a pretty dumb idea and i should rather learn it in a different way?

  • arthurno1@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 months ago

    Is this even “viable”, or advisable? Should i be looking at common lisp instead? Or would you say that’s a pretty dumb idea and i should rather learn it in a different way?

    You could have just tried any of previous years of AOC. Just go to their webpage and start doing them.

    You can do them in both elisp or cl or any other programming language, including bf. I think elisp works rather well for AOC, but it will really depend on your skills.

    You can look on their reddit and see if you can find elisp solutions from previous years to see if anyone has done some AOC challanges in elisp.

    How you will learn elisp depends on you. If you are discussing about learning it, you ain’t learning it, you are discussing. Programming is very similar to learning a new language, playing music or learning any other new skill. Just go and do anything, and you will learn something.

    • Piotr_Klibert@alien.topB
      link
      fedilink
      English
      arrow-up
      1
      ·
      11 months ago

      You could have just tried any of previous years of AOC. Just go to their webpage and start doing them.

      I did just that, to see how “viable” Elisp would be. I solved this: https://adventofcode.com/2022/day/1

      with:

      (cl-labels
          ((split-to-numbers (lst)
             (--map (->> (s-split "\n" it) (-map #'string-to-number)) lst)))
        (skip-chars-forward " \t\n")
        (let* ((input (buffer-substring-no-properties (point) (point-max)))
               (subs (->> input s-trim (s-split "\n\n") split-to-numbers))
               (sorted (cl-sort (-map #'-sum subs) #'>)))
          (message "Winner: %s" (car sorted))))
      

      and then with:

      (save-excursion
        (calc-pop (calc-stack-size))
        (while (progn (skip-chars-forward " \t\n") (not (eobp)))
          (save-selected-window
            (calc-grab-region (point) (progn (forward-paragraph) (point)) nil)
            (calc-eval "VR+" 'macro)))
        (calc-pack (calc-stack-size))
        (calc-vector-max nil)
        (calc-top-n 1))
      

      which turned out to be ~1000 times slower, but also worked.

      So u/domsch1988, it’s demonstrably doable in Elisp :)