Search code examples
netlogonested-lists

Netlogo operations on list of lists for example [ [100 0] [50 1] [30 2] ]


I am learning to program in NetLogo but I do not understand the following:

If we have a list of lists, how can I return the list with both the lowest item in the 0 index and the highest item in the 1 index?

For example, from:

[ [100 0] [50 1] [30 2] ]

It must be returned:

[30 2]

Solution

  • sort-by [ [i j] -> ( (item 1 i) > (item 1 j) and (item 0 i) < (item 0 j) ) ] mylist