Boost logo

Boost :

Subject: Re: [boost] De Bruijn Bind (alternate bind syntax) Interest?
From: David Sankel (camior_at_[hidden])
Date: 2010-09-02 13:11:03


2010/9/2 Dave Abrahams <dave_at_[hidden]>

> On Thu, Sep 2, 2010 at 11:57 AM, David Sankel <camior_at_[hidden]> wrote:
>
> > Hello all,
> >
> > I've been working on an alternate bind syntax based on De Bruijn
> > indices[1].
> > The syntax is very simple, yet the terms are very powerful.
> >
> > Here is an example of a function const that takes in an argument c and
> > returns another function that, for all input, returns c:
> >
> > //λx.λy.x = λλ1 with De Bruijn indices.
> >
>
> Not according to the page you linked below. What am I missing?
>
> [1] http://en.wikipedia.org/wiki/De_Bruijn_index
>

Sorry about that. The wikipedia page uses 1-indexed indices where I'm using
0-indexed indices. So, increment 1 on all my examples to get the wikipedia
syntax.

> For those of us without time to study up on functional lingo, it would be
> interesting to see some examples translated from a C++-ish lambda syntax
> (e.g. phoenix, C++0x lambdas, Bind) to your suggestion
>

A couple bind examples:

bind( f
    , bind( g
          , _1
          )
    )
=>
abs<1>( app( f
           , app( g
                , var<0,0>()
                )
           )
      )

bind( f
    , _1
    , boost::protect( bind( g
                          , 12
                          , _1
                          )
                    )
    )
=>
abs<1>( app( f
           , var<0,0>()
           , abs<1>( app( g
                        , 12
                        , var<0,0>()
                        )
                   )
           )
      )

The reverse direction is not always possible. For example:

abs<1>( app( f
           , var<0,0>()
           , abs<1>( app( g
                        , var<1,0>()
                        , var<0,0>()
                        )
                   )
           )
      )

does not have a corresponding bind.

David

-- 
David Sankel
Sankel Software
www.sankelsoftware.com
585 617 4748 (Office)

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk