Ah, yeah, I saw you mention that further down. I hear what you’re saying, then. :+1:
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?
Yup. Usually though in that scenario I just extract the long boring things to variables so I don’t have that problem.
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))
Shouldn’t it be able to infer that this should work?
If not, do I need to annotate cdr
somehow?
Yes, you need to either annotate cdr or argmax
Probably best to use inst to do that
sorry, i coun’t understand from the tutorial what the syntax is to annotate cdr
inst
ok thanks
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)))