True of false combined with "if"

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

True of false combined with "if"

rosuna
Hello:

This is my question. I am writing a model. Please, take a look at these two
different sentences:

If variable < 0 et variable = 0]

If (variable > 0) = false [set variable = 0]

The first writing leads to an error message, and the second one doesn't.
Therefore I know they are not equivalent.

My question is why is it, and what is the difference.

Thanks!




--
Sent from: http://netlogo-users.18673.x6.nabble.com/
Reply | Threaded
Open this post in threaded view
|

RE: [EXTERNAL] [netlogo-users] True of false combined with "if"

tswan73
If you remove the = from the set statements and write those statements as  [set variable 0], then both statements write the exact same output.



-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
Sent: Friday, September 08, 2017 5:53 PM
To: [hidden email]
Subject: [EXTERNAL] [netlogo-users] True of false combined with "if"

 

Hello:

This is my question. I am writing a model. Please, take a look at these two
different sentences:

If variable < 0 et variable = 0]

If (variable > 0) = false [set variable = 0]

The first writing leads to an error message, and the second one doesn't.
Therefore I know they are not equivalent.

My question is why is it, and what is the difference.

Thanks!

--
Sent from: Blockedhttp://netlogo-users.18673.x6.nabble.com/



Reply | Threaded
Open this post in threaded view
|

Re: True of false combined with "if"

Charles Ehlschlaeger-8
In reply to this post by rosuna
Hi Ruben,

The condition "variable < 0" reports true for all negative values of
variable.
The condition "(variable > 0) = false" reports true for all negative values
of variable and when variable equals 0.

I'm not sure of the behavior if variable is not a number. The best way to
find out is to try some experiments. For example:

set variable = "asdf"
ifelse (variable > 0) = false [ print "condition evaluated to true"] [
print "condition evaluated to false"]

You can do the same thing when variable is NaN and other special values of
NetLogo variables.

sincerely, chuck

--
Chuck Ehlschlaeger

"... incremental improvement is guaranteed to be obsolete over time." -
Larry Page
Reply | Threaded
Open this post in threaded view
|

Re: True of false combined with "if"

Bahman L.
In reply to this post by rosuna
 Dear Rosuna,
Technically, There is no difference between those two lines. The error might be because of "=" in the command. "Set" command does not take '='. Please try the following codes which both are identical.   
if variable < 0 [set variable 0] if (variable > 0) = false [set variable 0]
Regards, Bahman    On Monday, September 11, 2017, 9:04:28 PM GMT+4:30, rosuna [hidden email] [netlogo-users] <[hidden email]> wrote:

  
Hello:

This is my question. I am writing a model. Please, take a look at these two
different sentences:

If variable < 0 [set variable = 0]

If (variable > 0) = false [set variable = 0]

The first writing leads to an error message, and the second one doesn't.
Therefore I know they are not equivalent.

My question is why is it, and what is the difference.

Thanks!

--
Sent from: http://netlogo-users.18673.x6.nabble.com/

  #yiv3283610992 #yiv3283610992 -- #yiv3283610992ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv3283610992 #yiv3283610992ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv3283610992 #yiv3283610992ygrp-mkp #yiv3283610992hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv3283610992 #yiv3283610992ygrp-mkp #yiv3283610992ads {margin-bottom:10px;}#yiv3283610992 #yiv3283610992ygrp-mkp .yiv3283610992ad {padding:0 0;}#yiv3283610992 #yiv3283610992ygrp-mkp .yiv3283610992ad p {margin:0;}#yiv3283610992 #yiv3283610992ygrp-mkp .yiv3283610992ad a {color:#0000ff;text-decoration:none;}#yiv3283610992 #yiv3283610992ygrp-sponsor #yiv3283610992ygrp-lc {font-family:Arial;}#yiv3283610992 #yiv3283610992ygrp-sponsor #yiv3283610992ygrp-lc #yiv3283610992hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv3283610992 #yiv3283610992ygrp-sponsor #yiv3283610992ygrp-lc .yiv3283610992ad {margin-bottom:10px;padding:0 0;}#yiv3283610992 #yiv3283610992actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv3283610992 #yiv3283610992activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv3283610992 #yiv3283610992activity span {font-weight:700;}#yiv3283610992 #yiv3283610992activity span:first-child {text-transform:uppercase;}#yiv3283610992 #yiv3283610992activity span a {color:#5085b6;text-decoration:none;}#yiv3283610992 #yiv3283610992activity span span {color:#ff7900;}#yiv3283610992 #yiv3283610992activity span .yiv3283610992underline {text-decoration:underline;}#yiv3283610992 .yiv3283610992attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv3283610992 .yiv3283610992attach div a {text-decoration:none;}#yiv3283610992 .yiv3283610992attach img {border:none;padding-right:5px;}#yiv3283610992 .yiv3283610992attach label {display:block;margin-bottom:5px;}#yiv3283610992 .yiv3283610992attach label a {text-decoration:none;}#yiv3283610992 blockquote {margin:0 0 0 4px;}#yiv3283610992 .yiv3283610992bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv3283610992 .yiv3283610992bold a {text-decoration:none;}#yiv3283610992 dd.yiv3283610992last p a {font-family:Verdana;font-weight:700;}#yiv3283610992 dd.yiv3283610992last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv3283610992 dd.yiv3283610992last p span.yiv3283610992yshortcuts {margin-right:0;}#yiv3283610992 div.yiv3283610992attach-table div div a {text-decoration:none;}#yiv3283610992 div.yiv3283610992attach-table {width:400px;}#yiv3283610992 div.yiv3283610992file-title a, #yiv3283610992 div.yiv3283610992file-title a:active, #yiv3283610992 div.yiv3283610992file-title a:hover, #yiv3283610992 div.yiv3283610992file-title a:visited {text-decoration:none;}#yiv3283610992 div.yiv3283610992photo-title a, #yiv3283610992 div.yiv3283610992photo-title a:active, #yiv3283610992 div.yiv3283610992photo-title a:hover, #yiv3283610992 div.yiv3283610992photo-title a:visited {text-decoration:none;}#yiv3283610992 div#yiv3283610992ygrp-mlmsg #yiv3283610992ygrp-msg p a span.yiv3283610992yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv3283610992 .yiv3283610992green {color:#628c2a;}#yiv3283610992 .yiv3283610992MsoNormal {margin:0 0 0 0;}#yiv3283610992 o {font-size:0;}#yiv3283610992 #yiv3283610992photos div {float:left;width:72px;}#yiv3283610992 #yiv3283610992photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv3283610992 #yiv3283610992photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv3283610992 #yiv3283610992reco-category {font-size:77%;}#yiv3283610992 #yiv3283610992reco-desc {font-size:77%;}#yiv3283610992 .yiv3283610992replbq {margin:4px;}#yiv3283610992 #yiv3283610992ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv3283610992 #yiv3283610992ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv3283610992 #yiv3283610992ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv3283610992 #yiv3283610992ygrp-mlmsg select, #yiv3283610992 input, #yiv3283610992 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv3283610992 #yiv3283610992ygrp-mlmsg pre, #yiv3283610992 code {font:115% monospace;}#yiv3283610992 #yiv3283610992ygrp-mlmsg * {line-height:1.22em;}#yiv3283610992 #yiv3283610992ygrp-mlmsg #yiv3283610992logo {padding-bottom:10px;}#yiv3283610992 #yiv3283610992ygrp-msg p a {font-family:Verdana;}#yiv3283610992 #yiv3283610992ygrp-msg p#yiv3283610992attach-count span {color:#1E66AE;font-weight:700;}#yiv3283610992 #yiv3283610992ygrp-reco #yiv3283610992reco-head {color:#ff7900;font-weight:700;}#yiv3283610992 #yiv3283610992ygrp-reco {margin-bottom:20px;padding:0px;}#yiv3283610992 #yiv3283610992ygrp-sponsor #yiv3283610992ov li a {font-size:130%;text-decoration:none;}#yiv3283610992 #yiv3283610992ygrp-sponsor #yiv3283610992ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv3283610992 #yiv3283610992ygrp-sponsor #yiv3283610992ov ul {margin:0;padding:0 0 0 8px;}#yiv3283610992 #yiv3283610992ygrp-text {font-family:Georgia;}#yiv3283610992 #yiv3283610992ygrp-text p {margin:0 0 1em 0;}#yiv3283610992 #yiv3283610992ygrp-text tt {font-size:120%;}#yiv3283610992 #yiv3283610992ygrp-vital ul li:last-child {border-right:none !important;}#yiv3283610992