
@cyrille.deuss has joined the channel

To avoid flip
and take the currying one level deeper :slightly_smiling_face: (define (((compare/2 op) f) a b) (op (f a) (f b)))
(define ascending (compare/2 <))
(define descending (compare/2 >))
(define (pg lst) (sort lst (descending string-length)))
This exercise has made me appreciate the interface of Racket’s sort
more!

to turn a #\char into a string, you need to convert it to a list, then use (string->list) on it?

also does https://docs.racket-lang.org/reference/strings.html?q=string-%3Elist#%28def._%28%28quote._~23~25kernel%29._string-append-immutable%29%29\|string-append-immutable using the immutable version have a performance benefit?

@jestarray the string
function will do what you want, and no, it isn’t faster.

ohhhhhhh

my god, cant beleive i missed that lol

i want to match against a 2d list that is N length. match* (list (list 1 2 3) (list 4 5 6) (list 7 8))
[((? list?) (? list?) ...) #t])
I get: expected a sequence of expressions to match

I’m not sure what you are trying to do, but here’s how match*
is normally used:
(match* ((list 1 2 3) (list 4 5 6) (list 7 8))
[((? list?) (? list?) (? list?)) #t])

In particular, you cannot use ...
across values

Also, the first position of match*
is not a Racket list value. It’s values wrapped in parentheses.

If you want to match a list of list, you probably should use match
and not match*

(match (list (list 1 2 3) (list 4 5 6) (list 7 8))
[(list (? list?) ...) #t])

you cant use … in a match* ?

You can use ...
in a value, not across values

For instance, this works:
(match* ((list 1 2 3) (list 4 5 6) (list 7 8))
[((list (? number?) ...) (? list?) (? list?)) #t])

i need to distinct between a 2d list with N elements, and a 3d list with 1 element

Can you tell me exactly what you want to do?

Some concrete high-level examples would be nice

What do you mean by N elements and 1 element?