[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Fri, 13 Feb 2004 18:33:30 +0000 (UTC) 
Subject:Re:Re: how do I pass array parameters to external functions?thank you,But... 
From:Aaron Sloman 
Volume-ID: 

 Jenab writes:

> Date: Thu, 12 Feb 2004 08:01:58 +0000 (UTC)
 
> Hello.
> I used "newanyarray()" and "arrayvector()" as the following:
>
> vars m;
> newanyarray([1 2 1 2],{4 8 10 12},false)->m;

That creates a 2x2 array but it uses a "full" pop11 vector, which is
not compatible with external procedures as it can contain arbitrary
pop11 data-structures even though you include only integers.

See

    REF DATA
    REF VECTORS
    REF INTVEC

If you wish to pass the contents of an array of integers to an
external procedure maybe consintvec will create what you need, as
the integers it contains are represented in a mode that is
compatible with external procedures.

E.g.

    newanyarray([1 2 1 2], consintvec(#| 4, 8, 10, 12 |#), false) -> m;

    m(1,1) =>
    ** 4

    m(2,1) =>
    ** 10

    arrayvector(m) =>
    ** <intvec 4 8 10 12>

Note that

    consintvec(#| 4, 8, 10, 12 |#)

is equivalent to

    consintvec(4, 8, 10, 12, 4)

The brackets #| .... |# count the number of items left on the stack
between them and add an extra integer as a result (a very elegant
construct invented by Steve Leach I seem to remember).

Before that we had this more clumsy notation:

    cons_with consintvec {4 8 10 12}


> (I think this letter is text.)

Yes thank you. No html to get in the way.

Aaron
====
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT cs.bham.ac.uk   (ReadATas@please !)
PAPERS: http://www.cs.bham.ac.uk/research/cogaff/ (And free book on Philosophy of AI)
FREE TOOLS: http://www.cs.bham.ac.uk/research/poplog/freepoplog.html