+ Reply to Thread
Results 1 to 6 of 6

Thread: Expression Gate problem.

  1. #1
    Wire Noob stevenagainst's Avatar
    Join Date
    Dec 2009
    Posts
    1

    Default Expression Gate problem.

    Hi everyone,

    As I see, Expression gates are not able to calculate this code :huh::

    Code:
    Inputs: St
    Outputs: Hd
    
    if (St == 1) -> Hd = 99;
    if (St == 2) -> Hd = 90;
    if (St == 3) -> Hd = 80;
    if (St == 4) -> Hd = 71;
    if (St == 5) -> Hd = 61;
    if (St == 6) -> Hd = 52;
    if (St == 7) -> Hd = 42;
    if (St == 8) -> Hd = 33;
    if (St == 9) -> Hd = 23;
    So, I would like to know if there's another way I could write it... -_-

    Thank you!

  2. #2
    has a custom title mattwd0526's Avatar
    Join Date
    Apr 2009
    Location
    Born Bostonian
    Posts
    2,652

    Default Re: Expression Gate problem.

    That is because it doesn't follow the syntax. Take a look at some of the tutorials in the tutorial section. This code would be written

    Code:
    @inputs St
    @outputs Hd
    
    if (St == 1) {Hd = 99}
    elseif (St == 2) {Hd = 90}
    elseif (St == 3) {Hd = 80}
    elseif (St == 4) {Hd = 71}
    elseif (St == 5) {Hd = 61}
    elseif (St == 6) {Hd = 52}
    elseif (St == 7) {Hd = 42}
    elseif (St == 8) {Hd = 33}
    elseif (St == 9) {Hd = 23}

  3. #3
    Lifetime Supporter Nikita's Avatar
    Join Date
    May 2009
    Posts
    769

    Default Re: Expression Gate problem.

    Also, get rid of the habit of coding an if statement for every possible value and always try to find a mathematical equation if possible.
    Code:
    Hd= 108-9*St
    would be almost the same

  4. #4
    has a custom title mattwd0526's Avatar
    Join Date
    Apr 2009
    Location
    Born Bostonian
    Posts
    2,652

    Default Re: Expression Gate problem.

    Almost though, plus he obviously needs to learn how to code if statements.

  5. #5
    Spucatum Tauri Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    6,010

    Default Re: Expression Gate problem.

    Exact:
    Hd= ceil( 108 - 9.5 * St)
    My signature has a point.
    Quote Originally Posted by Squeakyneb View Post
    when l3ulletje says do it, do it.
    That

    Quote Originally Posted by Anticept View Post
    By the way, Bull is in charge.

  6. #6
    Wire Sofaking emspike's Avatar
    Join Date
    Feb 2008
    Posts
    911

    Default Re: Expression Gate problem.

    Quote Originally Posted by Bull View Post
    Exact:
    Hd= ceil( 108 - 9.5 * St)
    Some day I'm going to create a language that uses proper mathematical notation, forcing you to use ceiling brackets ^^.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots