NetLogo string concatenation?2019 Community Moderator ElectionWhat is the difference between String and string in C#?How do I iterate over the words of a string?How do I read / convert an InputStream into a String in Java?Case insensitive 'Contains(string)'How do I make the first letter of a string uppercase in JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?Does Python have a string 'contains' substring method?How do I convert a String to an int in Java?Why is char[] preferred over String for passwords?

How to terminate ping <dest> &

Does multi-classing into Fighter give you heavy armor proficiency?

I seem to dance, I am not a dancer. Who am I?

Unfrosted light bulb

Using Past-Perfect interchangeably with the Past Continuous

How might a highly intelligent aquatic species (mermaids) communicate underwater?

Recruiter wants very extensive technical details about all of my previous work

PTIJ What is the inyan of the Konami code in Uncle Moishy's song?

Pronounciation of the combination "st" in spanish accents

Existence of a celestial body big enough for early civilization to be thought of as a second moon

Do I need to be arrogant to get ahead?

gerund and noun applications

Can other pieces capture a threatening piece and prevent a checkmate?

Can a wizard cast a spell during their first turn of combat if they initiated combat by releasing a readied spell?

Relation between independence and correlation of uniform random variables

Why is there so much iron?

In Aliens, how many people were on LV-426 before the Marines arrived​?

Do native speakers use "ultima" and "proxima" frequently in spoken English?

Violin - Can double stops be played when the strings are not next to each other?

Do US professors/group leaders only get a salary, but no group budget?

Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?

What should I install to correct "ld: cannot find -lgbm and -linput" so that I can compile a Rust program?

Are dual Irish/British citizens bound by the 90/180 day rule when travelling in the EU after Brexit?

What (if any) is the reason to buy in small local stores?



NetLogo string concatenation?



2019 Community Moderator ElectionWhat is the difference between String and string in C#?How do I iterate over the words of a string?How do I read / convert an InputStream into a String in Java?Case insensitive 'Contains(string)'How do I make the first letter of a string uppercase in JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?Does Python have a string 'contains' substring method?How do I convert a String to an int in Java?Why is char[] preferred over String for passwords?










1















I'm trying to concatenate some characters into a string, and then do some conditional logic with the result, but instead of the expected "ABC", I get "[A][B][C]". How can I avoid that?



The code:



 let first [basetype] of nukleotider-here with [attached]
let second [basetype] of nukleotider-on patch-at 1 0
let third [basetype] of nukleotider-on patch-at 2 0

let kombination (word first second third)

if kombination = "ABC" [set looking-for "M"]


Thanks,
Palle










share|improve this question


























    1















    I'm trying to concatenate some characters into a string, and then do some conditional logic with the result, but instead of the expected "ABC", I get "[A][B][C]". How can I avoid that?



    The code:



     let first [basetype] of nukleotider-here with [attached]
    let second [basetype] of nukleotider-on patch-at 1 0
    let third [basetype] of nukleotider-on patch-at 2 0

    let kombination (word first second third)

    if kombination = "ABC" [set looking-for "M"]


    Thanks,
    Palle










    share|improve this question
























      1












      1








      1








      I'm trying to concatenate some characters into a string, and then do some conditional logic with the result, but instead of the expected "ABC", I get "[A][B][C]". How can I avoid that?



      The code:



       let first [basetype] of nukleotider-here with [attached]
      let second [basetype] of nukleotider-on patch-at 1 0
      let third [basetype] of nukleotider-on patch-at 2 0

      let kombination (word first second third)

      if kombination = "ABC" [set looking-for "M"]


      Thanks,
      Palle










      share|improve this question














      I'm trying to concatenate some characters into a string, and then do some conditional logic with the result, but instead of the expected "ABC", I get "[A][B][C]". How can I avoid that?



      The code:



       let first [basetype] of nukleotider-here with [attached]
      let second [basetype] of nukleotider-on patch-at 1 0
      let third [basetype] of nukleotider-on patch-at 2 0

      let kombination (word first second third)

      if kombination = "ABC" [set looking-for "M"]


      Thanks,
      Palle







      string netlogo






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 17:15









      pnowackpnowack

      425




      425






















          1 Answer
          1






          active

          oldest

          votes


















          3














          First, first is a reserved NetLogo primitive, but I'm assuming that you've translated your code into English for the purpose of posting it here (thanks!) In any case, I'm going to assume your variables are named x1, x2, and x3 instead of first, second and third.



          Your problem stems from the fact that the nukleotider-here and nukleotider-on reporters give you an agentset instead of a single agent. Consequently, of will give you a list instead of a single value.



          There are many ways out of that, but you should first ask yourself if you are certain that there will only ever be one nukleotider on each of the patch you're looking at. If you're sure of that, you can choose one of the following approaches:



          Extract the first items from the lists returned by of:



          let x1 first [basetype] of nukleotider-here with [attached]
          let x2 first [basetype] of nukleotider-on patch-at 1 0
          let x3 first [basetype] of nukleotider-on patch-at 2 0


          Extract the agent from the (presumably) single agent agentsets:



          let x1 [basetype] of one-of nukleotider-here with [attached]
          let x2 [basetype] of one-of nukleotider-on patch-at 1 0
          let x3 [basetype] of one-of nukleotider-on patch-at 2 0


          Delay the list extraction a bit:



          let x1 [basetype] of nukleotider-here with [attached]
          let x2 [basetype] of nukleotider-on patch-at 1 0
          let x3 [basetype] of nukleotider-on patch-at 2 0

          let kombination reduce word (sentence x1 x2 x3)


          Just turn into a list of strings and compare against that:



          let x1 [basetype] of nukleotider-here with [attached]
          let x2 [basetype] of nukleotider-on patch-at 1 0
          let x3 [basetype] of nukleotider-on patch-at 2 0

          let kombination (sentence x1 x2 x3)
          if kombination = ["A" "B" "C"] [set looking-for "M"]


          Even fancier:



          let kombination reduce word map [ xs -> [basetype] of one-of xs ] (list
          (nukleotider-here with [attached])
          (nukleotider-on patch-at 1 0 )
          (nukleotider-on patch-at 2 0)
          )


          OK, that last one might be overkill. And there would be even more ways to do it. But hopefully you find one that works for you... :-)






          share|improve this answer


















          • 1





            Fantastic, Nicolas. Of course. I completely overlooked the agent set problem. Yes, I'm completely sure, that there is only one "nukleotider" ("There can be only one!" as Christopher Lambert exclaimed in the eighties) - I just omitted the [with] clause to simplify the question. And yes, I translated from Danish into "First" etc. Thanks a billion!!! :-)

            – pnowack
            Mar 7 at 18:05










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55049456%2fnetlogo-string-concatenation%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          First, first is a reserved NetLogo primitive, but I'm assuming that you've translated your code into English for the purpose of posting it here (thanks!) In any case, I'm going to assume your variables are named x1, x2, and x3 instead of first, second and third.



          Your problem stems from the fact that the nukleotider-here and nukleotider-on reporters give you an agentset instead of a single agent. Consequently, of will give you a list instead of a single value.



          There are many ways out of that, but you should first ask yourself if you are certain that there will only ever be one nukleotider on each of the patch you're looking at. If you're sure of that, you can choose one of the following approaches:



          Extract the first items from the lists returned by of:



          let x1 first [basetype] of nukleotider-here with [attached]
          let x2 first [basetype] of nukleotider-on patch-at 1 0
          let x3 first [basetype] of nukleotider-on patch-at 2 0


          Extract the agent from the (presumably) single agent agentsets:



          let x1 [basetype] of one-of nukleotider-here with [attached]
          let x2 [basetype] of one-of nukleotider-on patch-at 1 0
          let x3 [basetype] of one-of nukleotider-on patch-at 2 0


          Delay the list extraction a bit:



          let x1 [basetype] of nukleotider-here with [attached]
          let x2 [basetype] of nukleotider-on patch-at 1 0
          let x3 [basetype] of nukleotider-on patch-at 2 0

          let kombination reduce word (sentence x1 x2 x3)


          Just turn into a list of strings and compare against that:



          let x1 [basetype] of nukleotider-here with [attached]
          let x2 [basetype] of nukleotider-on patch-at 1 0
          let x3 [basetype] of nukleotider-on patch-at 2 0

          let kombination (sentence x1 x2 x3)
          if kombination = ["A" "B" "C"] [set looking-for "M"]


          Even fancier:



          let kombination reduce word map [ xs -> [basetype] of one-of xs ] (list
          (nukleotider-here with [attached])
          (nukleotider-on patch-at 1 0 )
          (nukleotider-on patch-at 2 0)
          )


          OK, that last one might be overkill. And there would be even more ways to do it. But hopefully you find one that works for you... :-)






          share|improve this answer


















          • 1





            Fantastic, Nicolas. Of course. I completely overlooked the agent set problem. Yes, I'm completely sure, that there is only one "nukleotider" ("There can be only one!" as Christopher Lambert exclaimed in the eighties) - I just omitted the [with] clause to simplify the question. And yes, I translated from Danish into "First" etc. Thanks a billion!!! :-)

            – pnowack
            Mar 7 at 18:05















          3














          First, first is a reserved NetLogo primitive, but I'm assuming that you've translated your code into English for the purpose of posting it here (thanks!) In any case, I'm going to assume your variables are named x1, x2, and x3 instead of first, second and third.



          Your problem stems from the fact that the nukleotider-here and nukleotider-on reporters give you an agentset instead of a single agent. Consequently, of will give you a list instead of a single value.



          There are many ways out of that, but you should first ask yourself if you are certain that there will only ever be one nukleotider on each of the patch you're looking at. If you're sure of that, you can choose one of the following approaches:



          Extract the first items from the lists returned by of:



          let x1 first [basetype] of nukleotider-here with [attached]
          let x2 first [basetype] of nukleotider-on patch-at 1 0
          let x3 first [basetype] of nukleotider-on patch-at 2 0


          Extract the agent from the (presumably) single agent agentsets:



          let x1 [basetype] of one-of nukleotider-here with [attached]
          let x2 [basetype] of one-of nukleotider-on patch-at 1 0
          let x3 [basetype] of one-of nukleotider-on patch-at 2 0


          Delay the list extraction a bit:



          let x1 [basetype] of nukleotider-here with [attached]
          let x2 [basetype] of nukleotider-on patch-at 1 0
          let x3 [basetype] of nukleotider-on patch-at 2 0

          let kombination reduce word (sentence x1 x2 x3)


          Just turn into a list of strings and compare against that:



          let x1 [basetype] of nukleotider-here with [attached]
          let x2 [basetype] of nukleotider-on patch-at 1 0
          let x3 [basetype] of nukleotider-on patch-at 2 0

          let kombination (sentence x1 x2 x3)
          if kombination = ["A" "B" "C"] [set looking-for "M"]


          Even fancier:



          let kombination reduce word map [ xs -> [basetype] of one-of xs ] (list
          (nukleotider-here with [attached])
          (nukleotider-on patch-at 1 0 )
          (nukleotider-on patch-at 2 0)
          )


          OK, that last one might be overkill. And there would be even more ways to do it. But hopefully you find one that works for you... :-)






          share|improve this answer


















          • 1





            Fantastic, Nicolas. Of course. I completely overlooked the agent set problem. Yes, I'm completely sure, that there is only one "nukleotider" ("There can be only one!" as Christopher Lambert exclaimed in the eighties) - I just omitted the [with] clause to simplify the question. And yes, I translated from Danish into "First" etc. Thanks a billion!!! :-)

            – pnowack
            Mar 7 at 18:05













          3












          3








          3







          First, first is a reserved NetLogo primitive, but I'm assuming that you've translated your code into English for the purpose of posting it here (thanks!) In any case, I'm going to assume your variables are named x1, x2, and x3 instead of first, second and third.



          Your problem stems from the fact that the nukleotider-here and nukleotider-on reporters give you an agentset instead of a single agent. Consequently, of will give you a list instead of a single value.



          There are many ways out of that, but you should first ask yourself if you are certain that there will only ever be one nukleotider on each of the patch you're looking at. If you're sure of that, you can choose one of the following approaches:



          Extract the first items from the lists returned by of:



          let x1 first [basetype] of nukleotider-here with [attached]
          let x2 first [basetype] of nukleotider-on patch-at 1 0
          let x3 first [basetype] of nukleotider-on patch-at 2 0


          Extract the agent from the (presumably) single agent agentsets:



          let x1 [basetype] of one-of nukleotider-here with [attached]
          let x2 [basetype] of one-of nukleotider-on patch-at 1 0
          let x3 [basetype] of one-of nukleotider-on patch-at 2 0


          Delay the list extraction a bit:



          let x1 [basetype] of nukleotider-here with [attached]
          let x2 [basetype] of nukleotider-on patch-at 1 0
          let x3 [basetype] of nukleotider-on patch-at 2 0

          let kombination reduce word (sentence x1 x2 x3)


          Just turn into a list of strings and compare against that:



          let x1 [basetype] of nukleotider-here with [attached]
          let x2 [basetype] of nukleotider-on patch-at 1 0
          let x3 [basetype] of nukleotider-on patch-at 2 0

          let kombination (sentence x1 x2 x3)
          if kombination = ["A" "B" "C"] [set looking-for "M"]


          Even fancier:



          let kombination reduce word map [ xs -> [basetype] of one-of xs ] (list
          (nukleotider-here with [attached])
          (nukleotider-on patch-at 1 0 )
          (nukleotider-on patch-at 2 0)
          )


          OK, that last one might be overkill. And there would be even more ways to do it. But hopefully you find one that works for you... :-)






          share|improve this answer













          First, first is a reserved NetLogo primitive, but I'm assuming that you've translated your code into English for the purpose of posting it here (thanks!) In any case, I'm going to assume your variables are named x1, x2, and x3 instead of first, second and third.



          Your problem stems from the fact that the nukleotider-here and nukleotider-on reporters give you an agentset instead of a single agent. Consequently, of will give you a list instead of a single value.



          There are many ways out of that, but you should first ask yourself if you are certain that there will only ever be one nukleotider on each of the patch you're looking at. If you're sure of that, you can choose one of the following approaches:



          Extract the first items from the lists returned by of:



          let x1 first [basetype] of nukleotider-here with [attached]
          let x2 first [basetype] of nukleotider-on patch-at 1 0
          let x3 first [basetype] of nukleotider-on patch-at 2 0


          Extract the agent from the (presumably) single agent agentsets:



          let x1 [basetype] of one-of nukleotider-here with [attached]
          let x2 [basetype] of one-of nukleotider-on patch-at 1 0
          let x3 [basetype] of one-of nukleotider-on patch-at 2 0


          Delay the list extraction a bit:



          let x1 [basetype] of nukleotider-here with [attached]
          let x2 [basetype] of nukleotider-on patch-at 1 0
          let x3 [basetype] of nukleotider-on patch-at 2 0

          let kombination reduce word (sentence x1 x2 x3)


          Just turn into a list of strings and compare against that:



          let x1 [basetype] of nukleotider-here with [attached]
          let x2 [basetype] of nukleotider-on patch-at 1 0
          let x3 [basetype] of nukleotider-on patch-at 2 0

          let kombination (sentence x1 x2 x3)
          if kombination = ["A" "B" "C"] [set looking-for "M"]


          Even fancier:



          let kombination reduce word map [ xs -> [basetype] of one-of xs ] (list
          (nukleotider-here with [attached])
          (nukleotider-on patch-at 1 0 )
          (nukleotider-on patch-at 2 0)
          )


          OK, that last one might be overkill. And there would be even more ways to do it. But hopefully you find one that works for you... :-)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 7 at 17:59









          Nicolas PayetteNicolas Payette

          12k11824




          12k11824







          • 1





            Fantastic, Nicolas. Of course. I completely overlooked the agent set problem. Yes, I'm completely sure, that there is only one "nukleotider" ("There can be only one!" as Christopher Lambert exclaimed in the eighties) - I just omitted the [with] clause to simplify the question. And yes, I translated from Danish into "First" etc. Thanks a billion!!! :-)

            – pnowack
            Mar 7 at 18:05












          • 1





            Fantastic, Nicolas. Of course. I completely overlooked the agent set problem. Yes, I'm completely sure, that there is only one "nukleotider" ("There can be only one!" as Christopher Lambert exclaimed in the eighties) - I just omitted the [with] clause to simplify the question. And yes, I translated from Danish into "First" etc. Thanks a billion!!! :-)

            – pnowack
            Mar 7 at 18:05







          1




          1





          Fantastic, Nicolas. Of course. I completely overlooked the agent set problem. Yes, I'm completely sure, that there is only one "nukleotider" ("There can be only one!" as Christopher Lambert exclaimed in the eighties) - I just omitted the [with] clause to simplify the question. And yes, I translated from Danish into "First" etc. Thanks a billion!!! :-)

          – pnowack
          Mar 7 at 18:05





          Fantastic, Nicolas. Of course. I completely overlooked the agent set problem. Yes, I'm completely sure, that there is only one "nukleotider" ("There can be only one!" as Christopher Lambert exclaimed in the eighties) - I just omitted the [with] clause to simplify the question. And yes, I translated from Danish into "First" etc. Thanks a billion!!! :-)

          – pnowack
          Mar 7 at 18:05



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid …


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55049456%2fnetlogo-string-concatenation%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

          Can't find variable: document ReactNative Js2019 Community Moderator ElectionReactNative: how to center text?Can't find variable: navigate - ReactNative navigationReact Native error: “Can't find variable: TouchableHighlight”How to use Expo.DocumentPicker.getDocumentAsync properly. [Expo] [ReactNative]Can't find variable: regeneratorRuntime (ReactNative)Reactnative Expo It is advisable for a StartUp?Can't find variable : Self / Can't install firebaseNPM Install Error in installing ReactNative CLIContacts Displaying in App using ReactnativeFacebook login error: can't find variable: Alert

          Posting a File and Associated Data to a RESTful WebService preferably as JSON2019 Community Moderator ElectionREST URI convention - Singular or plural name of resource while creating itUploading both data and files in one form using Ajax?How do I upload a file with metadata using a REST web service?REST API - file (ie images) processing - best practicesSpring: JSON data and file in the same requestREST API Put large dataPosting a file and JSON data to Spring rest serviceRESTful Web Service Upload/Download Large Data With JSONREST API Design sending JSON data and a file to the api in same requestPost JSONArray to REST servicePUT vs. POST in RESTParsing values from a JSON file?JavaScript/jQuery to download file via POST with JSON dataHow do I upload a file with metadata using a REST web service?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?Separate REST JSON API server and client?what's the correct way to send a file from REST web service to client?How do I write JSON data to a file?What is “406-Not Acceptable Response” in HTTP?REST API - file (ie images) processing - best practices