Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy doesn't this fortran code work?
    text
    copied!<p>Hey, I wrote this (fortran) with the aim of finding the minimum spanning tree of a bunch of points (<em>syscount</em> of them). I know for a fact that this approach works, since i wrote it in javascript earlier today. js is slow though, and i wanted to see how much faster fortran would be!! only problem is it's not working, i'm getting an annoying error;</p> <blockquote> <p>prims.f95:72.43:</p> <p>if((check == 1) .and. (path(nodesin(j))(k) &lt; minpath)) then</p> <pre><code> 1 </code></pre> <p>Error: Expected a right parenthesis in expression at (1)</p> </blockquote> <p>What the hell is that about?! the 43rd character on the line is the "h" of "path"</p> <pre><code>nodesin(1) = 1 do i = 1,syscount-1 pathstart = -1 pathend = -1 minpath = 2000 do j = 1,i do k = 1, syscount check = 1 do l = 1, i if(nodesin(l) == k) then check = 0 end if end do if((check == 1) .and. (path(nodesin(j))(k) &lt; minpath)) then minpath = path(nodesin(j))(k) pathstart = nodesin(j) pathend = k end if end do end do nodesin(i+1) = pathend minpaths(i)(1) = pathstart minpaths(i)(2) = pathend end do </code></pre> <p>Also, i'm fairly new to fortran, so i have a few other questions;</p> <p>can i use &amp;&amp; instead of .and. ?</p> <p>is there a versions of the for(object in list){} loop found in many other languages?</p> <p>is there a verion of the php function in_array ? i.e. bool in_array(needle,haystack), and if there is, is there a better way of doing it than:</p> <pre><code>check = false Asize = size(array) do i = 1, Asize if(array(i) == needle) then check = true end if end do </code></pre> <p>then to using the check variable to see if it's there?</p> <p>(I haven't posted anything on stackoverflow before. please don't get angry if i've broken loads of etiquette things!)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload