rokitna
2020-12-5 13:27:25

Ah, yeah, I saw you mention that further down. I hear what you’re saying, then. :+1:


laurent.orseau
2020-12-5 17:34:55

I see, that makes sense. Nice rules. Are you following them strictly? For example, '(a (a (a (b something-rather-long-and-boring some-other-thing-also-rather-long)))) ;; A) Following the rule strictly: '(a (a (a (b something-rather-long-and-boring some-other-thing-also-rather-long)))) ;; B) Starting from the end. '(a (a (a (b something-rather-long-and-boring some-other-thing-also-rather-long)))) Are you still choosing option A?


notjack
2020-12-5 19:11:22

Yup. Usually though in that scenario I just extract the long boring things to variables so I don’t have that problem.


mskoh52
2020-12-5 20:19:42

i’m having some issue with this typed racket code where I try to find the index of the largest element of a list

(argmax cdr (for/list : (Listof (Pairof Integer Real)) ([i (in-range (length qs))] [q qs]) (cons i q))) It’s giving me this error:

; Argument 1: ; Expected: (-> a Real) ; Given: (All (a b) (case-> (-> (Pairof a b) b) (-> (Listof a) (Listof a)))) ; Argument 2: ; Expected: (Listof a) ; Given: (Listof (Pairof Integer Real))


mskoh52
2020-12-5 20:20:44

Shouldn’t it be able to infer that this should work?

If not, do I need to annotate cdr somehow?


samth
2020-12-5 20:21:37

Yes, you need to either annotate cdr or argmax


samth
2020-12-5 20:21:51

Probably best to use inst to do that


mskoh52
2020-12-5 20:21:53

sorry, i coun’t understand from the tutorial what the syntax is to annotate cdr


mskoh52
2020-12-5 20:22:12

inst ok thanks


mskoh52
2020-12-5 20:33:30

ok for anyone who is interested later on, this seems to work

(argmax (inst cdr Integer Real) (for/list : (Listof (Pairof Integer Real)) ([i (in-range (length qs))] [q qs]) (cons i q)))