You probably don't want a list... but you can always get one later.
To append to a list you use FPUT or LPUT. FPUT is faster for very long lists.
All the list modifiers actually don't modify anything. they take a
list, do something with it, and report a brand new list that reflects
;; pre-pend something to my-list
set my-list fput something my-list
But it sounds like you really could just use the WITH reporter to make
an agentset. Then if you need a list later (for ordered operations),
you can covert it:
turtles-own [ payees ]
;; a turtle runs this code:
set payees other turtles with [ amIpayee? true ]
Much more clear than the bulky code that would iterate a list of
turtles and append them to a list.
If you really need a list of turtles, you can make the agentset into a list:
;; convert payees set to a list
;; sort sorts a list, but also can convert agentset to list, then sort it.
set payees sort payees
On Mon, Mar 30, 2009 at 3:39 PM, bd2x <bdeshpan@...> wrote:
> Hi All,
> I am trying to add an agent to a list but clearly getting the syntax wrong.
> I looked thru the forum to see if there were any close solutions to my
> problem without success.
> Here is what i intend to do:
> create a new list called payeeList which is unique to each turtle (a turtle
> append those turtles which meet the criteria amIpayee? = TRUE to this list
> But at the very first loop, do i need to create the list before adding a
> member? (each loop adds either 0 or 1 turtle to this list).
> I am sure there are probably more efficient ways of doing this (using lists
> or otherwise) - kindly educate me on this!
> Thanks much.