massung
2021-8-4 16:59:25

Would this be the correct contract for a list that has at least 1 element in it? (list/c any/c any/c ...)


spdegabrielle
2021-8-4 16:59:46

laurent.orseau
2021-8-4 17:24:57

(and/c list? (not/c empty?)) should work too


massung
2021-8-4 17:25:54

ty


shu--hung
2021-8-4 18:35:26

+1 for @laurent.orseau’s suggestion.

(list/c X Y Z) describes lists of some specific length. Instead, another approach is (cons/c any/c list?) which gives a list with at least one element.


massung
2021-8-4 19:07:23

for my particular case, i wanted to ensure that the types of the list elements were matched (they aren’t any, just used that for an example). but seeing all the other options is good :slightly_smiling_face:


laurent.orseau
2021-8-4 19:21:46

You can also use list-of (or listof ? I never remember)


sorawee
2021-8-4 19:47:00

Right now there’s a problem with Rhombus installation, if I’m not mistaken. You need a Racket version after (inclusive) commit 5e75f7c but before (exclusive) cb23f25. Here’s a Racket installer that satisfies the constraint: https://plt.cs.northwestern.edu/snapshots/20210802-06d892f477/index.html


samdphillips
2021-8-4 19:51:18

I got 8.2.0.5 from Utah and it’s working for me


samdphillips
2021-8-4 19:51:33

Downloaded last night fwiw


samdphillips
2021-8-4 19:51:50

OIC


sorawee
2021-8-4 22:12:03

Is it possible to typeset an identifier so that a part of it is italicized, but the rest is not?


rokitna
2021-8-5 06:30:09

there’s a (non-empty-listof any/c) as it turns out :slightly_smiling_face: