Open andrewbaxter opened 7 months ago
Sorry, I think I was somewhat confused here. first/last/get
don't work on Validity
data, despite being described as a tuple:
{:create hos {state: String, year: Validity => hos: String}}
{
?[state, year, hos] <- [['US', [2001, true], 'Bush'],
['US', [2005, true], 'Bush'],
['US', [2009, true], 'Obama'],
['US', [2013, true], 'Obama'],
['US', [2017, true], 'Trump'],
['US', [2021, true], 'Biden']]
:put hos {state, year => hos}
}
{?[state, year] := *hos{state:state, year:year_}, year = first(year_)}
returns
help: 'first' requires lists
They seem to work fine for user-generated tuples.
Right now list methods don't work with tuples (error about not being a list value) and there are no tuple-specific methods.
I think I saw it mentioned somewhere else, but there's no way to extract values from a tuple AFAICT. Validities are a special case where
to_bool
andto_int
will extract the second and first values, but for user generated tuples there's no such option (and really,first
andlast
orget(, 0)
get(, 1)
would probably be clearer for those anyway).