Associative array/Creation: Difference between revisions
Content added Content deleted
(FutureBasic solution added) |
|||
Line 3,153: | Line 3,153: | ||
=={{header|Futhark}}== |
=={{header|Futhark}}== |
||
<syntaxhighlight lang="futhark">let associative_array = {key1=1,key2=2}</syntaxhighlight> |
<syntaxhighlight lang="futhark">let associative_array = {key1=1,key2=2}</syntaxhighlight> |
||
=={{header|FutureBasic}}== |
|||
<syntaxhighlight lang="futurebasic"> |
|||
void local fn DoIt |
|||
CFDictionaryRef dict1 = fn DictionaryWithObjects( @"Alpha", @"A", @"Bravo", @"B", @"Charlie", @"C", @"Delta", @"D", NULL ) |
|||
CFDictionaryRef dict2 = @{@"A":@"Alpha", @"B":@"Bravo", @"C":@"Charlie", @"D":@"Delta"} |
|||
CFMutableDictionaryRef dict3 = fn MutableDictionaryWithCapacity(0) |
|||
MutableDictionarySetObjectForKey( dict3, @"Alpha", @"A" ) |
|||
MutableDictionarySetObjectForKey( dict3, @"Bravo", @"B" ) |
|||
MutableDictionarySetObjectForKey( dict3, @"Charlie", @"C" ) |
|||
MutableDictionarySetObjectForKey( dict3, @"Delta", @"D" ) |
|||
CFMutableDictionaryRef dict4 = fn MutableDictionaryWithDictionary( @{@"A":@"Alpha", @"B":@"Bravo", @"C":@"Charlie", @"D":@"Delta"} ) |
|||
print fn DictionaryObjectForKey( dict1, @"A" ) |
|||
print dict1[@"B"] |
|||
print dict2[@"C"] |
|||
print dict3[@"D"] |
|||
print dict4 |
|||
end fn |
|||
fn DoIt |
|||
HandleEvents |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
Alpha |
|||
Bravo |
|||
Charlie |
|||
Delta |
|||
{ |
|||
A = Alpha; |
|||
B = Bravo; |
|||
C = Charlie; |
|||
D = Delta; |
|||
} |
|||
</pre> |
|||
=={{header|Gambas}}== |
=={{header|Gambas}}== |