1. Sequences

In EUPHORIA I read a file that was written in FORTRAN and it has the
following format:

  4I4

A record might look like this where "b" is considered to be a blank.

  bbb0bbb0bbb0bbb0

     or

   bb23b112bb34bb23

    or

  b103bb58bbb6bb23

I can go thru each record checking for blanks and probably convert the
numeric values but I have not found an easy way.  When I look at each
record in a sequence statement all four characters are in a group. There
has got to be a simple way to convert each 4 character field to an
integer.  It is my understanding that a dimension statement does not
exist in EUPHORIA.  Is this true?  The reason I ask is that as I unpack
each 4 characrter numbers in each record I would like to place it in a
buffer where I can use it as an integer for later calculations.

I guess I can place them back in a sequence to do all of my calculations.

If someone will help me with this simple problem I would be very
appreciative as I am still trying to convert a simple QB program to a
EUPHORIA program!

Thanks,
Jim Roberts

new topic     » topic index » view message » categorize

2. Re: Sequences

Jim Roberts wrote:
>
> In EUPHORIA I read a file that was written in FORTRAN and it has the
> following format:
>
>   4I4
>
> A record might look like this where "b" is considered to be a blank.
>
>   bbb0bbb0bbb0bbb0
>
>      or
>
>    bb23b112bb34bb23
>
>     or
>
>   b103bb58bbb6bb23
>
> I can go thru each record checking for blanks and probably convert the
> numeric values but I have not found an easy way.  When I look at each
> record in a sequence statement all four characters are in a group. There
> has got to be a simple way to convert each 4 character field to an
> integer.  It is my understanding that a dimension statement does not
> exist in EUPHORIA.  Is this true?  The reason I ask is that as I unpack
> each 4 characrter numbers in each record I would like to place it in a
> buffer where I can use it as an integer for later calculations.
>
> I guess I can place them back in a sequence to do all of my calculations.
>
> If someone will help me with this simple problem I would be very
> appreciative as I am still trying to convert a simple QB program to a
> EUPHORIA program!
>
> Thanks,
> Jim Roberts

off the top of my head, i'd say you needed an algorithm
that appears akin to:


numberlist = {}
   while not EOF do
        temp = {}
        for i= 1 to 4 do
           temp = temp & getc(FN)
        end for
        temp = value(temp)
        temp = temp[2] --check of course if all went well
        numberlist = numberlist & temp
   end while
return numberlist

and numberlist will have a list of valid integers
at each element location within it...
now, right off, my syntax and choice of getc
as opposed to other get?() functions could be
wrong here.... but i think you get the idear :)
not to mention the fact that the above code won't
even work ;)
hope this helps--Hawke'

new topic     » goto parent     » topic index » view message » categorize

3. Re: Sequences

On Sun, 8 Nov 1998 20:07:26 -0600, Jim Roberts <jhroberts1 at JUNO.COM> wrote:

>In EUPHORIA I read a file that was written in FORTRAN and it has the
>following format:
>
>  4I4
>
>A record might look like this where "b" is considered to be a blank.
>
>  bbb0bbb0bbb0bbb0
>
>     or
>
>   bb23b112bb34bb23
>
>    or
>
>  b103bb58bbb6bb23
>
>I can go thru each record checking for blanks and probably convert the
>numeric values but I have not found an easy way.  When I look at each
>record in a sequence statement all four characters are in a group. There
>has got to be a simple way to convert each 4 character field to an
>integer.  It is my understanding that a dimension statement does not
>exist in EUPHORIA.  Is this true?  The reason I ask is that as I unpack
>each 4 characrter numbers in each record I would like to place it in a
>buffer where I can use it as an integer for later calculations.
>
>I guess I can place them back in a sequence to do all of my calculations.
>
>If someone will help me with this simple problem I would be very
>appreciative as I am still trying to convert a simple QB program to a
>EUPHORIA program!
>
>Thanks,
>Jim Roberts
Here's my test file:
   1   2   3   4
  12  13  14  15
 110 111 112 112
4321432243234324

Here's tested (TESTED!) code:
include get.e -- for value function
object input
sequence n,nums
atom fn


fn = open("test.dat","r")
nums = {}
while 1 do
   input = gets(fn)
   if atom(input) then exit -- bye bye at eof
   elsif length(input) < 16 then exit -- or a blank line, whichever

   else
   puts(1,"Line in:" & input) -- show me what you've got
   for i = 1 to 16 by 4 do    -- for each field
       n = value(input[i..i+3]) -- convert from string to #
       nums = append(nums,n[2]) -- stick the # onto end of sequence
   end for
   end if
   puts(1,"Converted:") ? nums
end while

Regards,
Irv

new topic     » goto parent     » topic index » view message » categorize

4. Re: Sequences

------=_NextPart_000_000D_01C012C3.7622F8E0
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

The question Tony asked is EDS related.....

The sequence in the form {"first","second","third"}
is written to the database..

He then wants to read out the info which now is
{{first},{second},{third}}

and append the next sequence which should be

notice that we have one main sequence still,
try appending another sequence and you have an N-th sequence everytime =
you add a sequence........
i.e instead of {} becomes{{}} and
{{{}}} his program wont read past {{}} hence the problem.

I couldnt find a fast method, If any one has something to=20
fix this I would appreciate it....

euman at bellsouth.net





------=_NextPart_000_000D_01C012C3.7622F8E0
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4207.2601" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>The question Tony asked is EDS=20
related.....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>The sequence in the form=20
{"first","second","third"}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>is written to the =
database..</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>He then wants to read out the info =
which now=20
is</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>{{first},{second},{third}}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>and append the next sequence&nbsp;which =
should=20
be</FONT></DIV>
<DIV><FONT face=3DArial=20
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>notice that we have one main sequence=20
still,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>try appending&nbsp;another sequence and =
you have an=20
N-th sequence everytime </FONT><FONT face=3DArial size=3D2>you add a=20
sequence........</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>i.e instead of {} becomes{{}} =
and</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>{{{}}} his program wont read past {{}} =
hence the=20
problem.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I couldnt find a fast method, If any =
one has=20
something to </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>fix this I would&nbsp;appreciate=20
it....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><A=20
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>

------=_NextPart_000_000D_01C012C3.7622F8E0--

new topic     » goto parent     » topic index » view message » categorize

5. Sequences

Only variables can be subscipted or sliced, not literals or expressions.
Whether this should be the case is another question--I would vote for
subscipting/slicing of expessions in the next release.

-- Mike Nelson

new topic     » goto parent     » topic index » view message » categorize

6. Sequences

I have a quick question about sequences. How do I construct a
multidimensional type array with sequences? For example, in Basic I
would use:

Dim dataarray(3,6,4,3)

How would this be accomplished using euphoria?

Thanks,

Greg Harris

new topic     » goto parent     » topic index » view message » categorize

7. Re: Sequences

> I have a quick question about sequences. How do I construct a
> multidimensional type array with sequences? For example, in Basic I
> would use:
>
> Dim dataarray(3,6,4,3)
>
> How would this be accomplished using euphoria?

well obviously you can't "define" sequences in euphoria because of
its data allocation system...  but you have something like this:

sequence data_array

data_array =

hope that clarifies things :D

new topic     » goto parent     » topic index » view message » categorize

8. Sequences

Greg Harris writes:
> I have a quick question about sequences. How do I construct a
> multidimensional type array with sequences? For example, in Basic I
> would use:

> Dim dataarray(3,6,4,3)

In Euphoria you could construct this as:

   sequence dataarray
   dataarray = repeat(repeat(repeat(repeat(0,3),4),6),3)

Note the reverse order: 3 4 6 3

You could then access individual elements with:
   dataarray[h][i][j][k]

In BASIC subscripts start at 0.
In Euphoria they start at 1.

In Euphoria you aren't limited to "rectangular"
shapes for your multi-dimensional arrays.
For example, each "row" of a 2-d array (sequence) could be
a different length. Also, in Euphoria you can grow or shrink
your multi-dimensional sequence along any dimension at any time
without having to discard all your data, like some Basics require
when you "redim".

Regards,
  Rob Craig
  Rapid Deployment Software

new topic     » goto parent     » topic index » view message » categorize

9. Re: Sequences

At 10:42 PM 1/14/97 +0000, you wrote:
>---------------------- Information from the mail header -----------------------
>Sender:       Euphoria Programming for MS-DOS <EUPHORIA at
>MIAMIU.ACS.MUOHIO.EDU>
>Poster:       mike burrell <mikpos at GAIANET.NET>
>Subject:      Re: Sequences
>-------------------------------------------------------------------------------
>
>> I have a quick question about sequences. How do I construct a
>> multidimensional type array with sequences? For example, in Basic I
>> would use:
>>
>> Dim dataarray(3,6,4,3)
>>
>> How would this be accomplished using euphoria?
>
>well obviously you can't "define" sequences in euphoria because of
>its data allocation system...  but you have something like this:
>
>sequence data_array
>
>data_array =
>
>hope that clarifies things :D

Mike,
        Bob Craig was kind enough to suggest a neat way to me. I have
included it in the matrix.e file I expect to release to this group soon.
Consider:

        global function makeRowVector(integer column)
return repeat(0,columns)
        end function

        global function makeColumnVector(integer rows)
return repeat(repeat(0,1), rows)
        end function

        global function make2DMatrix(integer rows, integer columns)
return repeat(repeat(0,columns), rows)
        end function

        global function make3DMatrix(integer rows, integer columns, integer
layers)
return repeat(repeat(repeat(0,columns), rows), layers)
        end function

        In all cases, the 0 initializes the returned array to 0. Another
value could be used in the code directly or via an input parameter.

        Neat?
        Art Adamson

        For my use, I put the above in an include file called mat.e
        Then the following test program shows the results:

        --file testmat.ex
include mat.e
        ?  makeRowVector(3)
        ?  makeColumnVector(3)
        ?  make2DMatrix(3,4)
        ?  make3DMatrix(2,3,4)

--I'm sure the extension path for more dimensions is apparent to you.

        Bye Art
Arthur P. Adamson, The Engine Man, euclid at mail.horandata.net

new topic     » goto parent     » topic index » view message » categorize

10. Re: Sequences

>    sequence dataarray
>    dataarray = repeat(repeat(repeat(repeat(0,3),4),6),3)
> Note the reverse order: 3 4 6 3

I didn't realize that it was that easy.

> In BASIC subscripts start at 0. In Euphoria they start at 1.

I always did think that BASIC subscripting was a bit odd when it came
to arrays. Starting at one seems more logical to me.

> In Euphoria you aren't limited to "rectangular"
> shapes for your multi-dimensional arrays.
> For example, each "row" of a 2-d array (sequence) could be
> a different length. Also, in Euphoria you can grow or shrink
> your multi-dimensional sequence along any dimension at any time
> without having to discard all your data, like some Basics require
> when you "redim".

That could come in handy. Thanks for the help.

Greg.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu