User Tools

Site Tools


en:maps

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:maps [2020/04/23 15:17]
admin created
en:maps [2020/04/23 15:24] (current)
admin
Line 2: Line 2:
 Maps, also known ad dictionaries in Python, are created using the [[Map|Map]] statement.  They may hold numeric or string data.  Access to specific elements in a map is accomplished by using square brackets along with the string key associated with the element. Maps, also known ad dictionaries in Python, are created using the [[Map|Map]] statement.  They may hold numeric or string data.  Access to specific elements in a map is accomplished by using square brackets along with the string key associated with the element.
  
-You may use the [[arraylength|Array length]] [?] oerator or the [[Length|Length]] function.+You may use the [[arraylength|Array length]] [?] operator or the [[Length|Length]] function.
  
 +Internally maps are stores in alphabetic order. You may easily loop through a map using the [[fornext|For Next]] statement.
  
 +<code>
 +map grades
 +
 +grades['bob'] = 90
 +grades['mary'] = 96
 +grades['jimmy'] = 76
 +
 +total = 0
 +foreach name in grades
 + ? name, grades[name]
 + total = total + grades[name]
 +next name
 +
 +? "the class average is", total/length(grades)
 +</code>
 +displays
 +<code>
 +bob           90
 +jimmy         76
 +mary          96
 +the class average is        87.3333333333
 +</code>
  
 ==== History ==== ==== History ====
 |2.0.0.0|New to version| |2.0.0.0|New to version|
  
en/maps.1587676641.txt.gz · Last modified: 2020/04/23 15:17 by admin