Closed jo-sm closed 2 years ago
Hi, thanks for the report. I've raised this issue on the Discourse forum, hope we can get some answers there. You should just be able to use the main
branch, FWIW, rather than the "redux" branch. Not that you should have to do this manually, of course!
Re: questions on writing flows, I haven't been doing AoC but I've been thinking about joining. In the meantime, feel free to post your question either on the Discourse or on IRC and I'm happy to help!
Another resource you could look at if I / others are not available is the interactive qi tutorial.
To install it, follow these steps:
raco pkg install from-template
raco new qi-tutorial
And open the file tutorial.rkt
start.rkt
.
This is a more comprehensive tutorial than the Scribble docs at the moment (though they will eventually be kept up to date wrt each other) and I think it's a great format for learning a language.
@jo-sm It should work now. Could you please try again?
@countvajhula it works now, thanks for taking a look!
As far as the tutorial, I looked at the tutorial and I still didn't quite get how I would approach my problem so I'll reach out on Discourse or IRC soon š
@jo-sm Great! Let me know š
btw @jo-sm , I might have missed you in the Racket Discord during AoC, but I just noticed your repo and saw this comment:
If you wanted to "mapmap" using Qi, you could use ><
as you mentioned:
(define (mapmap f lst)
(~> (lst) ā³ (>< (map f _)) ā½))
(define lst (list (list 1 2 3) (list 2 3 4) (list 3 4 5)))
(mapmap add1 lst) ; => '((2 3 4) (3 4 5) (4 5 6))
You could also avoid the map
altogether:
(define (mapmap f lst)
(~> (lst) ā³ (>< (~> ā³ (>< f) ā½)) ā½))
Your main parser
function could also be done in one combined flow, something like:
(define-flow parser
(~> (string-split "\n")
(-< (~>> car
(string-split _ ",")
(map string->number))
(~>> cdr
(chunk _ 6)
(map cdr)
(mapmap (āÆ (~>> string-split (map string->number))))))
list))
You could also do the mapmap
part directly as part of the combined flow. Lots of options! š
I'm quite interested in learning how to use Qi š and am going to try to use it in some of my small personal projects or coding exercises. Thanks for creating it!
I tried to install it using
raco pkg install
but it seems to fail:I did get it to work by running the command
raco pkg install --type git-url "https://github.com/countvajhula/qi.git?path=qi-lib#reorganize-package-as-lib-test-doc-redux"
but this isn't great UX. Any thoughts?Also, I'm trying to play around with it a bit with parsing one of the inputs for the second Advent of Code challenge this year and I'm having some difficulty understanding how to approach the problem (specifically around dealing with two inputs in a flow). Is there some place that would be good to ask about it for some help or insight?