Re: Higher order programming: apply/3 implemented in swi



apply(F,Args,Term) :-
F =.. List,
append(List, Args, All),
Term =.. All.

Still, I don't see where your code is different in functionality from
the trivial code above. Ok, my code creates two intermediate lists that
can be avoided at the cost of a bit more programming, but your code
creates even more intermediate datastructures.

--- Jan

I read a bit superficial. I've just noticed this part of your message.
Yes, your code is more elegant, I just wasn't aware of the operator
"..". Thanks for pointing out.
.



Relevant Pages

  • Re: [QUIZ] Port a Library (#64)
    ... # left and right lists differ from the original list. ... this function returns a reference to such an array. ... def Merge::diff3 ...
    (comp.lang.ruby)
  • Re: "Criticism of the C programming language ??????"
    ... plug all the stupid holes (start defining things that are currently ... functionality available on most modern CPUs (and which is otherwise ... Another one, which you will realise if you use Lisp, is that in C there are too many ways to express the same thing - arrays of arrays of structures with arrays, or lists of list of lists. ...
    (comp.lang.c)
  • Re: parsing parameters
    ... (defmacro whatever (&rest args) ... "Evaluate BODY with the values in LIST bound according to ATTRIBUTE-SPEC. ... regular lambda lists, but only keyword symbols are allowed). ...
    (comp.lang.lisp)
  • Re: list.clear() missing?!?
    ... relevant idiom is fundamental (api expansions should be saved for rich ... where the named methods do not duplicate functionality provided by ... consistent with almost everything else you do to lists, ...
    (comp.lang.python)
  • Re: How to return information from a form?
    ... Sub AddArg ... Dim args As String ... "This application demonstrates how lists of values can be passed to a form ...
    (microsoft.public.access.gettingstarted)