C style 2*2 matrix

I think a table/matrix structure would be extremely useful. I would use it to give agents memory but there will be many other uses. What I really want is something as close as possible to
breakfast(1,2) = “bananas”
meaning the first row, second column of the agent’s breakfast variable is now bananas.
The current structures we have for anything close to this are confusing and not intuitive.

Hi @ThomasC, thanks for posting!

It sounds like you are aware of the existing extensions based on your last sentence, but just in case, here they are:

The syntax for these can indeed be confusing, especially if you don’t come from a Lisp background (NetLogo has its roots in Lisp). Maybe the type of syntax you suggest could be added in the future (I would certainly be in favor!).

1 Like

用嵌套的表格或列表封装一个对象可能会更合适,在目前netlogo内置的矩阵拓展对象中,每个元素以32位浮点数的格式映射到线性内存中,主要用于数学运算而不是存储和检索任意值。

It might be more appropriate to encapsulate an object with a nested table or list. In the current netlogo built-in matrix extensions, each element maps to linear memory in the form of a 32-bit floating-point number, used primarily for mathematical operations rather than storing and retrieving arbitrary values.

Are you talking about the Web version or the Desktop? They may have slightly different implementations.

I’ve only ever used the desktop version - I didn’t know coding in the web version is different!

Sorry I was referring to @maizi20’s answer :wink: Yes the extensions are internally differently implemented but the interface should be the same.

1 Like