RosettaCodeData/Task/Associative-array-Creation/EasyLang/associative-array-creation.easy

23 lines
517 B
Text
Raw Permalink Normal View History

2023-12-16 21:33:55 -08:00
# use array of array for this
2025-06-11 20:16:52 -04:00
func$ hget &arr$[][] ind$ .
for i to len arr$[][]
if arr$[i][1] = ind$ : return arr$[i][2]
2023-12-16 21:33:55 -08:00
.
2026-04-30 12:34:36 -04:00
return ""
2023-12-16 21:33:55 -08:00
.
2025-06-11 20:16:52 -04:00
proc hset &arr$[][] ind$ val$ .
for i to len arr$[][]
if arr$[i][1] = ind$
arr$[i][2] = val$
2023-12-16 21:33:55 -08:00
return
.
.
2025-06-11 20:16:52 -04:00
arr$[][] &= [ ind$ val$ ]
2023-12-16 21:33:55 -08:00
.
clothing$[][] = [ [ "type" "t-shirt" ] [ "color" "red" ] ]
clothing$[][] &= [ "size" "xl" ]
#
2025-06-11 20:16:52 -04:00
print hget clothing$[][] "color"
hset clothing$[][] "color" "green"
print hget clothing$[][] "color"