Consider this list:
the |list> => |number: 137> + |furniture: chair> + |animal: frog> + |furniture: table> + |number: 5573>The idea was we could filter this down to numbers using: |_pself>
number-filter |*> #=> |> furniture-filter |*> #=> |> animal-filter |*> #=> |> animal-number-filter |*> #=> |> number-filter |number: *> #=> |_self> animal-number-filter |number: *> #=> |_self> furniture-filter |furniture: *> #=> |_self> animal-filter |animal: *> #=> |_self> animal-number-filter |animal: *> #=> |_self>Now, put them to use:
sa: number-filter the |list> |number: 137> + |number: 5573> sa: furniture-filter the |list> |furniture: chair> + |furniture: table> sa: animal-filter the |list> |animal: frog> sa: animal-number-filter the |list> |number: 137> + |animal: frog> + |number: 5573>I don't yet have a use for this, but I'm pretty sure it will be useful eventually.
Update: if we did have projections, this is how we would define our filters:
number-filter |*> #=> |_pself><number: *||_self> furniture-filter |*> #=> |_pself><furniture: *||_self> animal-filter |*> #=> |_pself><animal: *||_self> animal-number-filter |*> #=> |_pself><animal: *||_self> + |_pself><number: *||_self>Update: Just an extra thing that would be fun:
-- define our operator: sa: how-many-numbers-in |*> #=> how-many number-filter |_self> -- try it out: sa: how-many-numbers-in the |list> 2|number: 1> + 3|number: 0>Which is not the answer you might expect! The reason is that our operator is linear. Let me expand that to show more clearly what I mean:
how-many-numbers-in the |list> == how-many-numbers-in (|number: 137> + |furniture: chair> + |animal: frog> + |furniture: table> + |number: 5573>) == how-many-numbers-in |number: 137> + how-many-numbers-in |furniture: chair> + how-many-numbers-in |animal: frog> + how-many-numbers-in |furniture: table> + how-many-numbers-in |number: 5573> == |number: 1> + |number: 0> + |number: 0> + |number: 0> + |number: 1> == 2|number: 1> + 3|number: 0>Now, for it to work the way you might expect, then we need learn-sp rules. And then something like:
sa: how-many-numbers-in (*) #=> how-many number-filter |_self> sa: how-many-numbers-in the |list>Which should give the desired result of |number: 2>
No comments:
Post a Comment