cyrille.deuss
2020-4-1 13:50:28

@cyrille.deuss has joined the channel


badkins
2020-4-1 16:15:23

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!


jestarray
2020-4-2 03:50:56

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



samth
2020-4-2 03:54:30

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


jestarray
2020-4-2 03:54:51

ohhhhhhh


jestarray
2020-4-2 03:54:55

my god, cant beleive i missed that lol


jestarray
2020-4-2 05:34:41

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


sorawee
2020-4-2 06:43:41

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])


sorawee
2020-4-2 06:43:56

In particular, you cannot use ... across values


sorawee
2020-4-2 06:44:59

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


sorawee
2020-4-2 06:47:13

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


sorawee
2020-4-2 06:47:41

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


jestarray
2020-4-2 06:47:58

you cant use … in a match* ?


sorawee
2020-4-2 06:48:13

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


sorawee
2020-4-2 06:49:02

For instance, this works:

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


jestarray
2020-4-2 06:49:17

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


sorawee
2020-4-2 06:49:35

Can you tell me exactly what you want to do?


sorawee
2020-4-2 06:50:07

Some concrete high-level examples would be nice


sorawee
2020-4-2 06:50:31

What do you mean by N elements and 1 element?