How does one match a list of items to function parameters?
apply
?
Such as (fn/10 (range 10))
(apply fn/10 (range 10))
?
ah I see
I somehow thought apply works one argument at a time
Is there a way to do a struct literal?
And is a struct a kind of declaration?
@slack1 yes, structs are a declaration
and there are struct literals for prefab structs
#s(p 1 2 3)
that’s a literal for a prefab struct named p
with 3 fields
mm thanks I shall read more on prefab structs
Should I/why should I prefer local define
s to let
s?
@brendan The Racket style guide says prefer define
https://docs.racket-lang.org/style/Choosing_the_Right_Construct.html#%28part._.Definitions%29
> Racket comes with quite a few definitional constructs, including let, let*, letrec, and define. Except for the last one, definitional constructs increase the indentation level. Therefore, favor define when feasible.
avoiding paren creep and indent creep is really the only reason, it’s not a big deal
ah, gotcha
yeah I came here from that section of the guide lol
AFAIK that’s the only authoritative word on the subject
I admit to personally preferring let
, but there is an advantage to internal definitions: they can be easily mixed.
oh I’ve been meaning to ask you about your let
preference :p
You can have a define
, a define-values
, a match-define
and even a struct
form together in the same internal definition context.