It sounds like you already have an understanding of what's going on. Jess maps arrays and multifields onto each other, copying in both directions. It's not done with efficiency in mind. There's no way to create an array explicitly -- Jess will turn a multifield into an array when calling a Java method that expects one. The type of the array will be inferred from the type of the data in the array. Likewise, anytime you call a Java function that returns an array, Jess will turn it into a multifield.
It sounds as though a collection of Userfunctions to serve as wrappers for your data structures would be in order. I think Jack Kerkhof wrote: > Sorry, I may have oversimplified my question with that example. > > I have an algorithm that requires efficient populating and referencing of a > static sized ordered set. The constraints of the problem point to arrays as > the most efficient way to accomplish this. > > I am trying to figure out if, for any java class, can you instance an array of > that class, and furthermore reference the > members of that array from jess: > > I.E. given the general java syntax: > > myClass[] myObjArray = new myClass[n] > // and then reference an element in the array of objects as: > myObjArray[i] ... > > Is there jess syntax that is equivalent to java's new myClass[n] ? > Is there jess syntax equivalent to java's myObjArray[i] ? > > One method is to populate a mulitfield, looping through n instances of (new > myClass), then reference them as (nth$ i). Being that it is efficiency I'm > after in creating an array in the first place, I suspect this would not have > any performance benefit over a java Vector, and probably not compete with a > java array. > > The other is to create an (Adapter pattern) class in java, effectively hiding > the required array syntax, but again at the cost of efficiency. > > Any other possibilities? > > Thanks, > > Jack > > > [EMAIL PROTECTED] wrote: > > > I think Jack Kerkhof wrote: > > > hi all, > > > > > > What would the Jess syntax be for the following java code snippet: > > > > > > String[] x = new String[2]; > > > x[0] = "hi "; > > > x[1] = "there"; > > > System.out.println(x[0]+x[1]); > > > > > > Jack > > > > > > > Well, I'm not sure what you're after, exactly. > > > > (bind ?x (create$ "hi " "there")) > > (printout t (str-cat (nth$ 1 ?x) (nth$ 2 ?x)) crlf) > > > > is one way to interpret your request, but that's probably not what > > you're looking for. Can you rephrase the question? > > > > --------------------------------------------------------- > > Ernest Friedman-Hill > > Distributed Systems Research Phone: (925) 294-2154 > > Sandia National Labs FAX: (925) 294-2234 > > Org. 8920, MS 9012 [EMAIL PROTECTED] > > PO Box 969 http://herzberg.ca.sandia.gov > > Livermore, CA 94550 > > > > -------------------------------------------------------------------- > > To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' > > in the BODY of a message to [EMAIL PROTECTED], NOT to the list > > (use your own address!) List problems? Notify [EMAIL PROTECTED] > > -------------------------------------------------------------------- > > > -------------------------------------------------------------------- > To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' > in the BODY of a message to [EMAIL PROTECTED], NOT to the list > (use your own address!) List problems? Notify [EMAIL PROTECTED] > -------------------------------------------------------------------- > --------------------------------------------------------- Ernest Friedman-Hill Distributed Systems Research Phone: (925) 294-2154 Sandia National Labs FAX: (925) 294-2234 Org. 8920, MS 9012 [EMAIL PROTECTED] PO Box 969 http://herzberg.ca.sandia.gov Livermore, CA 94550 -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------
