Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Persistent problem with creating a list (lput)

37 views
Skip to first unread message

Maxence Jacquet

unread,
Jan 6, 2025, 12:28:35 PMJan 6
to netlogo-users
Hello everyone,

I'm encountering a problem that tends to persist and I'm totally blocked. I'm new to netlogo.
This is the error I get after launching the commands: 

LPUT expected input to be a list but got the number 0 instead.
error while observer running LPUT
  called by procedure RUN-MULTIPLE-SIMULATIONS
  called by Button 'Start Multiple Simulations'

here is the sequence including lput :

to run-multiple-simulations [num-simulations]
set final-times [] 
let i 1
repeat num-simulations [
let random-density random 16 + 5 
setup-with-density random-density
reset-ticks 

set final-time nobody

while [any? parasitoids] [ 
go
]

if final-time != nobody [
set final-times lput final-time final-times
]

if final-time = nobody [
set final-times lput 0 final-times
]

display-final-time i last final-times 
set i i + 1
]
end

to display-final-time [simulation-number last-time]
let message (word "Simulation " simulation-number " : Final Time = " last-time)
user-message message 
end


If you want more informations, let me know.
Thank you very much for your help.

Maxence.

Michael Tamillow

unread,
Jan 6, 2025, 12:47:31 PMJan 6
to Maxence Jacquet, netlogo-users
I would get rid of this line

if final-time = nobody [
set final-times lput 0 final-times
]

I and instead initialize the final time list as

set final-time [0]

you could get rid of the if != nobody as well. But I fear your code has greater problems as well.

What are you trying to do here?

--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/netlogo-users/69a6a610-f3eb-4f99-98dd-ebe0d1ac1ce7n%40googlegroups.com.

Michael Tamillow

unread,
Jan 6, 2025, 12:48:55 PMJan 6
to Maxence Jacquet, netlogo-users
Nevermind, I do see final-times is a list and based on lput documentation, this should be right.... https://ccl.northwestern.edu/netlogo/docs/dict/lput.html

Aaron Andre Brandes

unread,
Jan 6, 2025, 2:06:40 PMJan 6
to Maxence Jacquet, netlogo-users

Hi Maxence,

I don’t see where your error is, but the message “LPUT expected input to be a list but got the number 0 instead.” Is consistent with the value of final-times having the default value 0. This could happen if it hadn’t been initialized, or was cleared by a command like clear-all or clear-globals. Since you use set with final-times it seems to be a global variable. Maybe something is going wrong in the go procedure.

 

Since you are new to NetLogo, it is probably worth trying to debug this by yourself. A basic technique is to print the value of a variable at various points to check whether it is changing as you expect.

You can find out about output commands such as print in the output section of the Programming Guide.

 

Alternatively, you can share more of your code.

 

- Aaron

-- 

Aaron Brandes, Software Developer

Center for Connected Learning and Computer-Based Modeling

 

 

--

Reply all
Reply to author
Forward
0 new messages