Associative array/Iteration: Difference between revisions
→{{header|Phixmonti}}
Line 2,579:
<lang Phixmonti>include ..\Utilitys.pmt
def getd /# dict key -- dict data #/▼
( ( ) ( ) ) var dictionary▼
dup if▼
else▼
drop "Unfound"▼
endif▼
enddef▼
def setd /# dict ( key data ) -- dict #/
1 get var ikey
2 get var idata
drop
p if
else
endif
var dictionary▼
enddef
▲def getd /# key -- data #/
▲ dictionary 1 get nip swap find nip
▲ dup if
▲ dictionary 2 get nip swap get nip
▲ else
▲ drop "Unfound"
▲ endif
▲enddef
def pair /# dict n -- dict ( k d ) #/
1 over 2 tolist var ikey
2 swap 2 tolist var idata
swap idata sget
2 tolist
enddef
def scandict /# dict n -- dict ( ) #/
for
pair
print nl
endfor
enddef
def pairs /# dict -- dict ( ) #/
0 scandict
enddef
Line 2,635 ⟶ 2,634:
/# ---------- MAIN ---------- #/
( "one" 1 ) setd
Line 2,642 ⟶ 2,643:
pairs nl
keys nl
values
</lang>
=={{header|PHP}}==
|