HOF Status
David Hakim <dhakim-Gkm/TONP9n1Wk0Htik3J/[email protected]> Tue, 25 Feb 2003 18:34:29 -0500
| Newsgroups | gmane.comp.lang.moto.devel |
|---|---|
| Message-ID | <[email protected]> |
It looks like I'm about done with the major changes I want to make for the first cut of HOFs . Sorry, no anonymous functions / closure support yet ... it won't be too hard to add tho :) I'm going through trying to add some functions and methods to the extensions that will show off the power of the new new constructs. Here are some interesting possibilities I've come up with so far. Let me know if you guys have others you'd like to see! -Dave int strcmp(String,String) - good ole strcmp ... useful for passing on to sort functions Vector::Vector(Object[]) - Creates a Vector from an Object[] void Vector::sort(int compfn(Object,Object)) - Quicksort! sub(Regex rx, String(Match) substitution, String input) - Functional regex substitution ... check out hof_fsub.moto to see the moto implementation each(boolean[] arr, void(boolean) fn) - obvious each(byte[] arr, void(byte) fn) each(char[] arr, void(char) fn) each(double[] arr, void(double) fn) each(float[] arr, void(float) fn) each(int[] arr, void(int) fn) each(long[] arr, void(long) fn) each(Object[] arr, void(Object) fn) Object[] sort(Object[] arr, int compfn(Object,Object)) - quicksort for arrays Enumeration Vector::select(Object[] arr, boolean selectfn(Object)) - return an enumeration of objects in the vector matching qualities selected for by the selector int Vector::delete(Object[] arr, boolean selectfn(Object)) - delete objects in the vector matching qualities selected for by the selector int Vector::update(Object[] arr, boolean selectfn(Object), void updatefn(Object)) - replace objects in the vector matching qualities selected for by the selector Hashtable::Hashtable(int compfn(Object,Object), int hashfn(Object,Object)) - instantiate a new hashtable which can use any type of Object as a key! Enumeration Tokenizer::tokens() - return an enumeration of all the tokens this would ever return Enumeration::each(void(Object)) - pass a function to be called on each object in the enumeration e.g. stab.keys().each(&output(<Object>?)) IntEnumeration::each(void(int))