Skip to content
  • Home
  • #MeditatingWithViqui
    • Agenda
    • English sessions
    • Sessoes em portugues
    • Sesiones en Espanol
  • About
  • Papers’n Books
  • Personal Manifesto
Search
Close

Blog da Viqui

Feeling… Sharing… Expanding…

Tag: lists

Lessons learnt with NetLogo: how to change an item of a list in a list (“list of list”)

August 18, 2017 ViquiLeave a comment

According to the text in the NetLogo dictionary “”replace-item” is used in conjunction with “set” to change a list”. But how is it done? And how does it work with list of lists?

  • Answer to the first question (how to use the primitive replace-item to change a list):
    • Let’s say that you have a list [1 2 3 4 5] called myList and you want to replace the first item by the string “a”. Check the picture below for an example using the command center:
    • Capture3
    • So, it is only “re-setting” the list replacing the desired item by the desired value.
  • Now the answer to the second question (how to use the primitive replace-item to change an item in a list that is inside another list – that’s in a “list of list”):
    • If you try to do it directly using the same procedure presented above, the result will be that the original list will be truncated. All other sublists will be lost and the only remaining is the one whose item was modified. Please check the pic below:
    • Capture4
    • As you could see, the original list was lost. Only remaining the sublist with the item changed. This happens, because the sintax of the primitive replace-item considers the second argument (replace-item index list value) as one single simple list.
    • To solve this issue, that’s to have the item of the list inside a list modified and preserve the original list, you have to use an auxiliar list. Check the pic below:
    • Capture
    • So, I have used the auxiliar list auxList to receive the value of the internal list I wanted to modify, and then I replaced the whole item of the original list myList using the sintax presented before (treating it as a simple list then).

I hope it helps. It helped me a lot. 🙂

Lessons learnt with NetLogo: how to sum elements of a “list of list”

August 17, 2017August 18, 2017 ViquiLeave a comment
  1. The primitive sum does not work for “list of list” ( e.g. [ [1] [1] [1]]).  To solve this issue, I discovered that I can use “sum of sum”. Like: sum [ sum property] of agentset. The sum inside the brackets will turn the list into a simple list (in contrast to the list of list that would be obtained otherwise) and the sum outside the brackets will perform the sum you want. Please see an example from the model I am building below (the property sugarProductionMill is itself a list in the way I coded it): Capture1 This is not explicit in the explanation given in the NetLogo Dictionary – as you can also check below:  Capture2

Categories

Enter your email address to follow this blog and receive notifications of new posts by email.

Follow Blog da Viqui on WordPress.com

Tags

#EconomiaCircular #Livro #Simbiose Industrial #EcologiaIndustrial #IndustrialEcology #IndustrialSymbiosis #CircularEconomy #Book #MeditandoComAViqui #MeditandoConLaViqui #MeditatingWithViqui Abundance Agent based modeling Agroindústria Amor Artigo Bioeconomia Biorrefinaria Biorrefino Born to be free Brasil cherishing the self Coppe Coppetex Creativity/Criatividade Crítica Daily Desenvolvimento Do facebook Doutorado Emaye Ama Mizani Encounters Energia EUA EuInvestigadoradeMim experience FocusingOnWhatIWant Friendship Health IndustrialSymbiosis/SimbioseIndustrial Ingles Latex Learning liberdade Life purpose list of list lists Livestream Livro Love LovingMyself100% Meditacao Meditacion Meditation melanina Mujica music negro NetLogo PhD poder Poetisando PuttingLightIntoTheShadows Quando a magica acontece Racismo Referências Reflexão Respect RetiroEspiritualSemanal Science SeguraOCu Self-acceptance Self-love Self Knowledge Selma de Fátima Santos ser negro Sugarcane surprises Sustainability Trusting the Universe UFRJ WorkInProgress

Top Posts & Pages

  • Adaptando template LaTex de tese Coppe/UFRJ para quem vai escrever a tese em ingles
  • Lessons learnt with NetLogo: how to sum elements of a "list of list"
  • Lessons learnt with NetLogo: how to change an item of a list in a list ("list of list")
  • Silêncio Criativo: Meditação coletiva para o autocuidado

No upcoming events

Web Analytics //static.getclicky.com/js try{ clicky.init(101069602); }catch(e){}

Clicky

Create a free website or blog at WordPress.com.
Back to top
Cancel
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy