Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!psuvax1!psuvm.bitnet!psuvmxa!cunyvm!byuvax!hallidayd From: hallidayd@yvax.byu.edu Newsgroups: comp.lang.fortran Subject: Re: Pointer examples and 8x Message-ID: <661hallidayd@yvax.byu.edu> Date: 28 Jun 89 03:11:14 GMT Lines: 40 Chris Torek (chris@mimsy.UUCP), see if the following function is not a direct port of your C code (message <18236@mimsy.UUCP>, with corrections given in message <18265@mimsy.UUCP>) to Fortran 8x. TYPE (NODE), POINTER FUNCTION INSERT (HEAD, NEWNODE) ! I believe this to ! be proper syntax ! for such a FUNCTION TYPE (NODE), POINTER :: HEAD, NEWNODE TYPE (NODE), POINTER :: PTR INTEGER :: NUMBER = NEWNODE % VALUE ! I believe the syntax ! allows the initial- ! ization to involve ! the arguments in ! this way. ! (It should.) PTR => HEAD DO, WHILE (ASSOCIATED (PTR % NEXT) .AND. PTR % NEXT % VALUE < NUMBER) ! This (and the C code) work ! because the .AND. operator ! is a "short circuit" form. ! (See Ada for a language that ! distinguishes between short ! circuiting and non-short ! circuiting logical operators.) PTR => PTR % NEXT END DO NEWNODE % NEXT => PTR % NEXT PTR % NEXT => NEWNODE INSERT = HEAD END FUNCTION INSERT _____________________________________ / David Halliday \ | | | Internet: hallidayd@yvax.byu.edu | | BITNET: hallidayd@byuvax | | Us Mail: BYU Physics Department | | 296 ESC | | Provo, UT 84602 | \_____________________________________/