1. Structured programming

Hi All,

I just thought of another way to abuse Structure Programming using Euphoria.
I submit the program below as a well structured code example - it has no
goto, and only consists of simple functions and has no variables that are
defined external to functions that the functions can gain access to.

(Don't try this at home, kids. It's just a joke, okay.)

----------------
   include misc.e

   function F1(sequence z)
      return {"F5", {"oll" & z}}
   end function

   function F2(sequence Flda, sequence Fldb)
      return {"F4", {reverse(Flda), reverse(Fldb)}}
   end function

   function F3(sequence PartA, sequence PartB)
      printf(1, PartA, PartB)
      return {"",""}
   end function

   function F4(sequence X, sequence Y)
      return {"F3",{"%s, %s!\n", {'H' & X, 'W' & Y}}}
   end function

   function F5(sequence Text)
      return {"F2", {Text, "dlro"}}
   end function

   procedure main(sequence InitFunc, sequence InitData)
      sequence Stack

      Stack = {routine_id(InitFunc),{InitData}}
      while Stack[1] != -1 do
          Stack = call_func( Stack[1], Stack[2])
          Stack[1] = routine_id(Stack[1])
      end while
   end procedure

   main("F1", "e")

------------------
cheers,
Derek Parnell
Senior Design Engineer
Global Technology Australasia Ltd
dparnell at glotec.com.au

---------------------




confidential information intended solely for the use of the individual or
entity to whom they are addressed. If you are not the intended recipient of
this message you are hereby notified that any use, dissemination,
distribution or reproduction of this message is prohibited. If you have
received this message in error please notify the sender immediately. Any
views expressed in this message are those of the individual sender and may
not necessarily reflect the views of Global Technology Australasia Limited.

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu