Tobin:
Much better would be for this to be a static method in ptolemy.data.expr.UtilityFunctions. Then it automagically becomes a function in the expression language...
Edward
At 02:04 PM 7/30/2004 -0700, Tobin Fricke wrote:
On Fri, 30 Jul 2004, Edward A Lee wrote:
> cons = function(car:double, cdr:{double}) arrayJoin({car}, cdr) > > However, on quick glance, it looks like we don't have built-in > primitives like arrayJoin... This is an oversight... We need those... > Volunteer to create a set of such functions?
Here's an attempt at a 'concatenate' method for ArrayToken. It would be useful to have a similar method for 1xN and Nx1 matricies ('vectors'). Any suggestions for other array methods? Python has 'append', 'extend' (like concatenate), insert, remove, pop, index (like 'find'), sort, reverse, and a mechanism to get subarrays.
Tobin
--- ArrayToken.java.org 2004-07-30 11:26:41.000000000 -0700 +++ ArrayToken.java 2004-07-30 14:05:26.000000000 -0700 @@ -385,6 +385,22 @@ return new ArrayToken(zeroValueArray); }
+ /** Returns a new ArrayToken containing first all the elements of this + array token and then all the elements of the ArrayToken given as an + argument (i.e., the concatenation of these ArrayTokens). + @return An ArrayToken + @exception IllegalActionException + */ + public ArrayToken concatenate(ArrayToken arg) + throws IllegalActionException { + int nElements = this.length() + arg.length(); + Token combinedArray[] = new Token[nElements]; + System.arraycopy(this._value, 0, combinedArray, 0, this.length()); + System.arraycopy(arg._value, 0, combinedArray, this.length(), + arg.length()); + return new ArrayToken(combinedArray); + } + /////////////////////////////////////////////////////////////////// //// protected methods ////
---------------------------------------------------------------------------- Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]
------------ Edward A. Lee, Professor 518 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0455, fax: 510-642-2739 [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal
---------------------------------------------------------------------------- Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]