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?
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
add a comment |
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
add a comment |
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
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
string netlogo
asked Mar 7 at 17:15
pnowackpnowack
425
425
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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... :-)
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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... :-)
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
add a comment |
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... :-)
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
add a comment |
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... :-)
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... :-)
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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