Io language uses arguments'

In the Io programming language, there is an equivalent to the lisp apply function.

So, for example, I have a method for wrap writnn:

mymeth := method(
              //do some extra stuff

             writeln(call message arguments))
)

At the moment, it just prints the list and does not evaluate its contents, as if it were its own arguments.

+5
source share
2 answers

Thanks to the person who suggested evalArgs (I don't know where your comment went).

In any case, this was resolved for my situation, although, unfortunately, I do not think at all.

You can achieve what I describe:

writeln(call evalArgs join)

This evaluates all the arguments, and then combines the results into a single line.

+3
source

Is there an equivalent to the lisp apply function?

Take a look performand performWithArgList.


, lisp FUNCALL Io:

1 - , .. ():

plotf := method (fn, min, max, step,
    for (i, min, max, step,
        fn call(i) roundDown repeat(write("*"))
        writeln
    )
)

plotf( block(n, n exp), 0, 4, 1/2 )

2 - :

plotm := method (msg, min, max, step,
    for (i, min, max, step,
        i doMessage(msg) roundDown repeat(write("*"))
        writeln
    )
)

plotm( message(exp), 0, 4, 1/2 )

3 - :

plots := method (str, min, max, step,
    for (i, min, max, step,
        i perform(str) roundDown repeat(write("*"))
        writeln
    )
)

plots( "exp", 0, 4, 1/2 )


lisp APPLY :

apply := method (
    args := call message argsEvaluatedIn(call sender)
    fn   := args removeFirst
    performWithArgList( fn, args )
)

apply( "plotf", block(n, n exp), 0, 4, 1/2 )

apply( "plotm", message(exp), 0, 4, 1/2 )

apply( "plots", "exp", 0, 4, 1/2 )
+2

All Articles