On Sat, Jul 29, 2023 at 11:31:17AM +0200, Grégory Vanuxem wrote:
> Hello,,
>
> I am asking myself what is the best/efficient domain to return a list
> of key pairs.
>
> I can not use List(Record),
List of records is "best" for problem as stated above.
> first I am not a big fan of hardcoded
> "domains" in FriCAS core, and second I do not know the keys in
> advance.
AFAICS you now types of keys (String), and that is enough to define
a Record.
> I explain, I am adding regular expression support to custom strings
> (JuliaString) and when the regular expression captures substring they
> can be named.
>
> Take this regex:
> regex:= "(?<hour>\d+):(\d+)(am|pm)?"
> and "11:30 in the morning" to search in.
>
> Actually, I return a List(JuliaString),
> ====================================
> (7) -> l:=jlRegexMatch(regex,s)@List(JSTR)
>
> (7) ["11", "30", ""]
> Type: List(JuliaString)
> ====================================
> But I would like to also add the (key, value) pairs support:
> "hour" => "11",
> "minutes" => "30"
> "3" => ""
> the regular expression code is in Julia (PCRE2 is used from Julia
> documentation) but in FriCAS do you have any idea which domain I could
> use, AssociationList is not exposed for example?
>
> Note: that's just utility code for strings.
Just use AssociationList. For return values it does not matter
much if domain is exposed or not.
--
Waldek Hebisch