Re: Sequences

new topic     » goto parent     » topic index » view thread      » older message » newer message

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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu