Ehr... in fact, I was not :-P In fact, the implementation of |+| that
comes from this is composition, which is of course another natural
operation. I did not hitnk of it
2014-12-05 18:55 GMT+01:00 Björn Lindqvist :
> I wonder, are you aware that quotations are just a type of sequence? So:
>
>
I wonder, are you aware that quotations are just a type of sequence? So:
[ * ] [ number>string print ] append [ 3 9 ] dip call
Does what you would expect. :) You can even "add" stack effects and
the algebra will work out:
( x -- ) ( x x x -- x x ) compose-effects
2014-12-05 11:10 GMT+0
Those solutions don't check to make sure both quotations have the same
effect, or at least the same number of effect inputs, you might want to add
some of that for production-type code :-)
On Fri, Dec 5, 2014 at 7:37 AM, Andrea Ferretti
wrote:
> Wow, you and Factor never stop to surprise me! :-)
Wow, you and Factor never stop to surprise me! :-)
2014-12-05 16:23 GMT+01:00 John Benediktsson :
> And more generally, using the ``generalizations`` vocabulary:
>
> M: quotation |+|
> dup infer in>> length [ nbi |+| ] 3curry ;
>
> On Fri, Dec 5, 2014 at 7:22 AM, John Benediktsson wrote:
>>
>
And more generally, using the ``generalizations`` vocabulary:
M: quotation |+|
dup infer in>> length [ nbi |+| ] 3curry ;
On Fri, Dec 5, 2014 at 7:22 AM, John Benediktsson wrote:
> You could use the stack-checker to infer the effect of the quotation and
> then dispatch like this:
>
> ```
>
You could use the stack-checker to infer the effect of the quotation and
then dispatch like this:
```
M: quotation |+|
dup infer in>> length {
{ 1 [ [ bi |+| ] 2curry ] }
{ 2 [ [ 2bi |+| ] 2curry ] }
{ 3 [ [ 3bi |+| ] 2curry ] }
} case ;
```
But you might start run
Hi, I am trying to implement monoids in factor. A monoid is a set with
a binary associative operation (and, depending on the defintiion, a
neutral element for it).
Typical examples are numbers (with either addition or multiplication)
or sequences (with concatenation). Other examples can be derived