On Wed, Oct 15, 2008 at 7:46 AM, Timothy Pratley <[EMAIL PROTECTED]> wrote: > > Can I get some help with (map f coll)... > > What I want to do is map a java function that takes 2 arguments over a > list > where the first argument is the index into the list itself > and the second argument is taken from the list > > The problem being map uses a function of 1 argument. > Does that mean I need to create my own map, or is there a better way?
map can take more than one argument. If it has N arguments, it calls f with N arguments, each taken from the Nth value of each collection. So you should be able to pass in an infinite sequence like this UNTESTED code: (map f coll (range (count coll))) Jim > > > Specifically what I'm struggling with: > > (def *scene-graph* (new javax.media.j3d.BranchGroup)) > > (defn poly [label points] > (let [la (new javax.media.j3d.LineArray (count points) > (.COORDINATES javax.media.j3d.LineArray)] > (map (memfn javax.media.j3d.LineArray.setCoordinate idx (new > javax.vecmath.Point3f x y 0) points) > (.addChild *scene-graph* (new javax.media.j3d.Shape3D la)))) > > The intention being that points is a list of x,y coordinates > I construct a LineArray which is the size of points > then for every point I need to call setCoordinate(index, Point3f(x,y)) > The LineArray then makes a Shape3D which can be added to the scene > graph. > > > Regards, > Tim. > > > > > > > > -- Jim Menard, [EMAIL PROTECTED], [EMAIL PROTECTED] http://www.io.com/~jimm/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---