How to transform a list where each item is a number from 1 to 31 in NetLogo?

Solution 1:

You can use the position command. According to the NetLogo Manual it needs the inputs item list and reports the position of the item in the list, starting from 0. That's why you have to add a 1 to it.

An example:

globals [ValidHabs]

to go
  set ValidHabs [ [1] [2] [3] [4] [5] [1 2] [1 3] [1 4] ]
  show get-profile [1 2] ;reports 6
end

to-report get-profile [habitats]
  report (position habitats ValidHabs) + 1
end