map:: implicit list arguments problem

E.Silber
2006-07-25
2013-04-19
  • E.Silber

    E.Silber - 2006-07-25

    Hi,
    I'm trying to map println onto a list,
    but it fails, what is wrong with this picture?:

    public class Junk
    {
        public static void main(String[] args)
        {
            Object[] lst = {"aaa",123,"bbb","ccc"};
           
           Function f = new StaticFunction(
                   System.out.getClass(),"println");
           Functions.map( f, lst );
        }

    }

    generates an Exception that seems to suggest
    the function println was not invoked with a
    known signature?:
    Also, how would I in and addParameter,
    refer to the list element? ( Perl uses
    $_ for that) i.e. so that I could say
    addParameter(currentElt.toString())
    ??

    java Junk
    Exception in thread "main" info.javelot.functionalj.FunctionException: No possible targets were found for name 'println' on class class java.io.PrintStream with parameters []
            at info.javelot.functionalj.ReflectionFunction.<init>(ReflectionFunction.java:122)
            at info.javelot.functionalj.MethodFunction.<init>(MethodFunction.java:102)
            at info.javelot.functionalj.MethodFunction.<init>(MethodFunction.java:84)
            at info.javelot.functionalj.MethodFunction.<init>(MethodFunction.java:69)
            at info.javelot.functionalj.StaticFunction.<init>(StaticFunction.java:41)
            at Junk.main(Junk.java:39)

     
    • E.Silber

      E.Silber - 2006-07-25

      Never mind,  I took it out of the box
      without enough RTFM.   Declared as an
      InstanceFunction, no problem.

      Great library, helps cut out a lot of
      unneeded typing in Java!

       
      • Fred Daoud

        Fred Daoud - 2006-07-26

        Hi,

        Glad you found a solution to the problem.

        Thanks for your kind comments and your interest in FunctionalJ!

        Frederic

         

Log in to post a comment.