A little example looking like yours:
set my-list 
ask turtles [
foreach [who] of turtles-here with [who > 100] [? -> set my-list fput ? my-list ]
So in your case you should put :
foreach [who] of turtles-here with… ;; verify that this is a list
[ ? -> set encountered fput ? encountered ]
You can continue to use ?, ?1 etc or any letter or name for these anonymous variables (foo is an option).
The trick is the "->" mapping tour anonymous variable to the procedure you want it to execute (here building a list).
See for more the transition guide from v. 5 to v.6.0 on the NL site
foreach [who] of turtles-here with [breed != participant and not
(member? who [encountered] of myself)]
[ id ->
set encountered fput id encountered
That is, rather than using the special variables ? and ?1, ?2, etc, you now
name the variables, separating the list of variables from the code to run
with ->. For more than one variable, you surround the list of variables
with . For instance, (foreach list1 list2 [ [a b] -> print a + b ]).
This is much nicer as you can now, for instance, use multiple nested foreachs
without the special variables colliding:
foreach range 5 [ x ->
foreach range 5 [ y ->
crt 1 [ setxy x y ]
Furthermore, you can now do, eg, nested maps, which was not possible before: