Hi,

> I've considered adding apply to REBOL for many years.  Every few
months I write a script that could use it.
>
> Also, here is another way to do nargs:
>
> nargs: func [f [any-function!]] [
>    -1 + index? any [find first :f refinement!  tail first :f]
> ]
>
> -Carl
>

didn't know, that Find can search for datatypes. Is
there a plan to control the Find behaviour with any refinements
wrt. datatypes? (See example)

find compose [1 2 (integer!) 3 (datatype!) 4] datatype!
== [datatype! 4]

I tried a simpler implementation of Apply and it looks that it is
about ten times faster, than the previous one.

Rebol [
    Title: "Apply"
    Date: 21/5/2000
    File: %apply.r
    Author: "Ladislav Mecir"
    Email: [EMAIL PROTECTED]
    Purpose: {
        Apply a function to its arguments stored in a block
    }
    Comment: {
        much simpler/faster implementation,
        compatible with zero-agument functions, as opposed to the
previous version
    }
]

apply: func [
    {Apply a function to its arguments}
    f [any-function!]
    blkargs [block!] {Argument values}
    /local length statement result
] [
    statement: make block! (length: length? blkargs) * 3 + 3
    insert statement [set/any 'result f]
    repeat i length [
        append statement [pick blkargs]
        append statement i
    ]
    do statement
    get/any 'result
]

{
    Example:

    apply :subtract [2 1]
    apply :type? reduce [()]
}


    Ladislav






Reply via email to