Table Example

Table Example preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)



Tagged by Modeling Commons System over 12 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 765 times • Downloaded 52 times • Run 0 times
Download the 'Table Example' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

extensions [table]

globals [t]

to test1

  ;; create the table
  set t table:make

  ;; table:put  
  ;; associate  with  in the table
  table:put t 0 "test-value"
  table:put t "test-key" 1

  ;; table:get 
;; reports the value in the table associated with ;; if there is no value set for the key, returns 0 if table:get t 0 != "test-value" [ user-message "should be \"test-value\"" ] if table:get t "test-key" != 1 [ user-message "should be 1" ] ;; table:keys
;; reports all keys in the table as a list output-print table:keys t ;; table:length
;; reports the number of key->value pairs in the table output-print table:length t ;; table:has-key?
;; reports true if there is a value associated with the key in the table if ( not table:has-key? t 0 ) [ user-message "should contain 0" ] if ( not table:has-key? t "test-key" ) [ user-message "should contain test-key" ] if ( table:has-key? t "arbitrary" ) [user-message "should not have the arbitrary key" ] ;; you can print a table output-print t ;; table:clear
;; clears all key->value associations in the table table:clear t if table:length t != 0 [ user-message "should have no entries" ] end; Public Domain:; To the extent possible under law, Uri Wilensky has waived all; copyright and related or neighboring rights to this model.

There are 3 versions of this model.

Uploaded by When Description Download
Uri Wilensky about 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky over 11 years ago Updated version tag Download this version
Uri Wilensky over 12 years ago Updated from NetLogo 5.0 Download this version

Attached files

File Type Description Last updated
Table Example.png preview Preview for 'Table Example' about 11 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.