Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Some Help

  1. #1
    New to the CF scene
    Join Date
    Mar 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Some Help

    Code:
    for($i=1; $i < $array.length; $i++){
      for($j=1; $j < $array1.length; $j++){
        if($array[$i] && $array1[$j] == $dominant){
          //code
        }elseif($array[$i] == $dominant && $array[$j] == $recessive){
          //code
        }elseif($array[$i]==$recessive && $array[$j] == $dominant){
          //code
        }elseif($array[$i] && $array1[$j] == $recessive){
          //code
        }else{
          die;
        }
        }
        }
    Basically with this, I'm taking user input (From dropdown boxes, so no worries on if it'll screw up) , and putting it into array and array1. Then i'm running through these arrays, and checking if each value is dominant or recessive and comparing them. Basically now, i'm trying to figure out how to add to the probability of each thing getting pulled out. The only problem is, there may be more than one dominant or recessive for each subset, and they need to stay separate. Where it says //code, could I do something like :

    Check to determine what kind of trait it is
    Then add to something like $Trait1Final
    Then take all of the "Final" vars and put them in to an array and use the maths to get the probability of drawing one?

    Basically, I'm trying to make this

    http://gyazo.com/eb9fcebd9557903f4c57da7e8f7b396c

    Thanks for any help .

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,493
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    So you have a 2-dimensional array ... across (columns) and down (rows)?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •