After talking quite a lot on IRC with Betel about this, I must admit I see no super clear solution. There are a couple of options as I see it, each with their issues, so I am hoping I have missed something
The one I am most inclined to see happen is:
Code: Select all
(index source target keyIndex) -> index
It's only downside is that it is rather narrow in it's application, and still requires two calls, one to get the data and one to get the index
Betel suggests this one instead, as a more versatile version:
Code: Select all
(index source expression) -> index
The idea is that it will return the index of the first element in source where the expression evaluates to non Nil.
The problem I see with this is the speed hit of using an expression. Otherwise a nice function.
Then there is a version which does it all in one go:
Code: Select all
(index source target keyIndex) -> '(index '(data))
or
(lookup source target keyIndex -> '(index '(data))
Well... even though this is the version I would find most useful, it is probably also the one furthest from the lisp way. I will leave you or Betel to chop the rest of this one down
The last idea addresses my problem with transmute, having to enum over all elements in tscript
Code: Select all
(lookupTransmute source target keyIndex expression) -> '(new source)
or
(transmute source target keyIndex expression) -> '(new source)
Now, this is a bit of a mongrel... The idea is that the matching be done in C to take advantage of the speed, but leave the transmuting up to tscript. It would be cool if the expression would be applied to all possible matches of target. Perhaps this is the most powerful of these suggestions, but the function signature is a bit intimidating...
In either case I hope this brings something to the table
