From: Jamie W. <j...@jm...> - 2004-02-02 02:01:15
|
On Sunday 01 February 2004 19:03, Reuben Thomas wrote: > the functionalised operators +, -, .. &c. -- not sure how best to > -- include these, e.g. how to name them, how general they > -- really should be (arity &c.) Naming: yeah, dunno. Arity: I decided it made sense only for commutative operators to be variadic. > The following I plain don't understand: > > function std.getter(name) -- what's this for? > function std.method(name, ...) -- what's this for? > function std.bind_method(t, m) -- what's this for? Say I have a list of objects and I want to get a list of those which have attribute foo = true: footrue = std.filter(std.getter("foo"), objects) Say I want to call method swizzle(5) on each of a list of (maybe polymorphic) objects: results = std.map(std.method("swizzle", 5), objects) bind_method() as I said is just a convenience. It means I can write std.bind_method(object, "method", ...) rather than std.bind(object.method, object, ...). It just happens that I had some code where I needed to do that a lot. > I'm dubious about the following: > > function std.map_tbl(f, t) -- it is really wise to map over a table? > function std.filter_tbl(f, t) -- these should only be used on > lists/arrays IMO Why not? Changing the keys is maybe not such a great idea, but there doesn't seem to be any reason not to map/filter over the values. Obviously the order is undefined, but that's just expected from any operation on tables. I don't really see why one shouldn't map (most likely injections) over sets either. > function std.conjunction(...) -- this seems a bit specialised; > it's really reverseMap composed > with functionalised "and" Fair enough. I just didn't think of that; I've never come across reverseMap before. I don't see it in your library though. -- Jamie Webb |