filter enhancements
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark
Re: filter enhancements
for those that missed that thread could you elaborate?
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Re: filter enhancements
@monte, well, assuming @mwieder and I are talking about the same instance it is this:
I responded assuming that didn't really work. After the above comment, I don't really know.
Code: Select all
filter tGood with ("*" & item 1 of gCodes & "*") or ("*" & item 2 of gCodes & "*") or ("*" & item 3 of gCodes & "*")
Re: filter enhancements
It would be nice if it did...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Re: filter enhancements
(I thought I had missed something.)
Yeah it would be nice. Maybe with 'each' like with sort.
Yeah it would be nice. Maybe with 'each' like with sort.
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: filter enhancements
If it worked it would save me a lot of multiple copying, but I'm not sure it's the syntax I'd choose, probably opting for something like
Code: Select all
filter tGood matching regex "*[" & item 1 to 3 of gCodes & "]*"
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Re: filter enhancements
Once I get around to implementing filter-map-reduce, you could use arbitrary boolean expressions in your filter script:
I think that would allow you to convert most 'repeat for each' filtering loops.
Jan Schenkel.
Code: Select all
filter theList by item 3 of each is "foo" or item 6 of each is "bar"
filter theList by each begins with "baz" and each ends with "qux"
filter theList by MyBooleanFunction(each) into theFilteredList
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: filter enhancements
Yes, filter-map-reduce would be a great addition, but I think the syntax is getting less xtalky.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: filter enhancements
I think Jan's suggestion is very xtalky. Maybe I'm missing something. I would have integrated it into a different approach for this based on cool (hopefully xtalky) syntax for application and reduction in general, but what he has is good for this limited scope. And 'each' is an established concept; we should let it earn its keep.
I'm not saying it is the best xtalky syntax. I would not have used 'by'. But it is shorter than 'keeping lines where'.
I'm not saying it is the best xtalky syntax. I would not have used 'by'. But it is shorter than 'keeping lines where'.
Re: filter enhancements
Maybe this can be an expression:
Code: Select all
get the lines of x where (item 3 of each) = 3
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Re: filter enhancements
Heh, I'm definitely not married to my originally proposed syntax - 'by' makes sense for the 'sort' command, but not so much for 'filter'...
Just looked at the dictionary to refresh my memory, and we already have the 'mark' command which uses 'where' for its conditional clause.
So I'll probably adopt 'where' instead of 'by'.
Once I have the time to work on it, I'll open a new topic on this forum, and we can flesh out the filter-map-reduce syntax.
Jan Schenkel.
Just looked at the dictionary to refresh my memory, and we already have the 'mark' command which uses 'where' for its conditional clause.
So I'll probably adopt 'where' instead of 'by'.
Code: Select all
filter theList where item 3 of each is "foo" or item 6 of each is "bar"
filter theList where each begins with "baz" and each ends with "qux"
filter theList where MyBooleanFunction(each) into theFilteredList
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Re: filter enhancements
Hmmm. "keeping lines where" is not that long if we also have "keeping items where" and and so on.
I look forward to your bringing this up Jan when you are ready.
(I do like the idea of expressions for mapping, reducing, selecting and logical-ing over chunks but I might be the only one to use them.)
I look forward to your bringing this up Jan when you are ready.
(I do like the idea of expressions for mapping, reducing, selecting and logical-ing over chunks but I might be the only one to use them.)
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: filter enhancements
Code: Select all
filter theList where item 3 of each is "foo" or item 6 of each is "bar"
filter theList where each begins with "baz" and each ends with "qux"
filter theList where MyBooleanFunction(each) into theFilteredList
@Dar-
I seriously doubt thatI might be the only one to use them.
This is gonna be really useful. I just have in the back of my mind the idea that there's a more "natural language" way to express this, it just isn't coming to me right now. And of course, expressing complex boolean expressions in natural language can be prone to errors., i.e.,
Code: Select all
filter xyzzy with a and b or c or d and item 3 of e or f -- wtf?
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: filter enhancements
Is there any reason with and without can't work?
It's probably worth pointing out that with a few tweaks you've got some basic SQL like syntax...
Code: Select all
filter thelist with item 3 of each is "foo"...
Code: Select all
select item 1 to 3 from theList where item 3 of each is "foo"...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Re: filter enhancements
Well you have to differentiate the intent somehow at the syntax level. Maybe we'll have both 'where' and 'by' as synonyms, just like the pairs 'with'/'matching' and 'without'/'not matching' - so developers can write what best fits their coding style. On the other hand, multiple ways to express the same logic always run the risk of cognitive overload and confusion for whoever needs to read the code.monte wrote:Is there any reason with and without can't work?
But we're getting ahead of ourselves here, as it will be a few weeks before I can get into that project.
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Re: filter enhancements
@monte, I'd rather go closer to FOL than to SQL.
@mwieder, maybe it would be a good exercise to try expressing some of these in our own English style and ignoring LiveCode for a bit. It is hard for me. I keep thinking LiveCode, but you might be able to do it. My first try for filtering:
...the lines of x where each line begins with quote and each line ends with quote...
...the lines of x where each begins with quote and each ends with quote...
...the items of flyList where each item is a number...
...the words of y where character 4 of each word is "a", all as lines...
...the elements of z where each is a number and test(each)...
...the integer indexed elements of z as lines...
...the lines of x where each is among the items of y where y is a number...
...the lines of x where each is among the items of (the items of y where y is a number)...
...scrambleItems( the lines of x as items ) as lines...
...the lines of x that are not empty...
...the lines of x that begin and end with quote...
...the nonempty lines of x as integer indexed elements...
...the lines of x not in y...
...the lines of x that are not in y...
...the lines of x, call each y, such that p(y)...
Maybe some of those work.
This sounds fun but is not what Jan is thinking and might be scary for most language thinkers and implimenters.
@mwieder, maybe it would be a good exercise to try expressing some of these in our own English style and ignoring LiveCode for a bit. It is hard for me. I keep thinking LiveCode, but you might be able to do it. My first try for filtering:
...the lines of x where each line begins with quote and each line ends with quote...
...the lines of x where each begins with quote and each ends with quote...
...the items of flyList where each item is a number...
...the words of y where character 4 of each word is "a", all as lines...
...the elements of z where each is a number and test(each)...
...the integer indexed elements of z as lines...
...the lines of x where each is among the items of y where y is a number...
...the lines of x where each is among the items of (the items of y where y is a number)...
...scrambleItems( the lines of x as items ) as lines...
...the lines of x that are not empty...
...the lines of x that begin and end with quote...
...the nonempty lines of x as integer indexed elements...
...the lines of x not in y...
...the lines of x that are not in y...
...the lines of x, call each y, such that p(y)...
Maybe some of those work.
This sounds fun but is not what Jan is thinking and might be scary for most language thinkers and implimenters.