This  looks great!

On Sat, Aug 29, 2009 at 4:01 PM, Eduardo Cavazos <[email protected]>wrote:

> Hello,
>
> Below is an interpretation of some concatenative combinators in Scheme.
>
> Here are some simple examples:
>
> > ((bi sin cos list) 0)
> (0 1)
> > ((tri sin cos tan list) 0)
> (0 1 0)
> > ((bi* sin cos list) 0 0)
> (0 1)
> > ((tri* sin cos tan list) 0 0 0)
> (0 1 0)
> > ((bi@ sqrt list) 4 9)
> (2 3)
> > (define square (dup *))
> > (square 4)
> 16
> > (define cube (dup (dup/2 *)))
> > (cube 3)
> 27
>
> While in Factor there is 'bi' and 'tri', what is the unary case and what
> does it mean?
>
> (define (uni f c)
>   (lambda (x)
>     (c (f x))))
>
> It is simply compose.
>
> Ed
>
> ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> (define (bi f g c)
>   (lambda (x)
>     (c (f x)
>        (g x))))
>
> ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> (define (tri f g h c)
>   (lambda (x)
>     (c (f x)
>        (g x)
>        (h x))))
>
> ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> (define (bi* f g c)
>   (lambda (x y)
>     (c (f x)
>        (g y))))
>
> ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> (define (tri* f g h c)
>   (lambda (x y z)
>     (c (f x)
>        (g y)
>        (h z))))
>
> ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> (define (bi@ f c)
>   (lambda (x y)
>     (c (f x)
>        (f y))))
>
> ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> (define (dup c)
>   (lambda (x)
>     (c x x)))
>
> ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> (define (dup/2 c)
>   (lambda (x y)
>     (c x y y)))
>
> ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> (define (swap c)
>   (lambda (x y)
>     (c y x)))
>
> ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> (define (drop c)
>   (lambda (x)
>     (c)))
>
> ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> (define (drop/2 c)
>   (lambda (x y)
>     (c x)))
>
> ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> (define (ifte test ca cb)
>   (lambda (x)
>     (if (test x)
>         (ca x)
>         (cb x))))
>
> ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to