[plt-scheme] Android; compiling to Java byte code; Clojure

From: Benjamin L. Russell (dekudekuplex at yahoo.com)
Date: Sat Nov 24 17:27:02 EST 2007

Putting the entire procedure into a single loop would
definitely solve the problem, since that would
alleviate the need for mutual recursion.

I suppose it may be possible to combine all three
local local procedures init, more, and end into a
single local procedure, which I shall call
"init-more-end" for the time being, and to use recur
to recur on this single local procedure, perhaps
somewhat similarly to as follows?

(def machine [stream]
  (let [fn [init-more-end stream]
            (cond
              [(empty? stream) true]
              [else
              (if (eql? [first stream] (c))
                  (loop [stream (rest stream)]
                    (case [first (rest stream)]
                      [(a) (recur [rest stream])]
                      [(d) (recur [rest stream])]
                      [(r) (cond 
                           [(empty? stream) true]
                           [else
                             (case (first stream)
                               [else false])])])))])])
  (init))

Would this be closer to the solution?

Benjamin L. Russell

--- Shriram Krishnamurthi <sk at cs.brown.edu> wrote:

> This is exactly what I meant by my parenthetical
> remark,
> "I think this example is not so hard with RECUR".
> 
> [Robby of course knew what I was referring to; this
> clarification is
> for the benefit of others following along at home.]
> 
> Shriram
> 
> On Nov 24, 2007 4:14 PM, Robby Findler
> <robby at cs.uchicago.edu> wrote:
> > I'm just guessing, but it seems likely to me that
> you could generate a
> > single loop with some kind of a dispatch in the
> loop, since you know
> > all of the states at the time you expand the macro
> (of course, the
> > expansion won't be as nice as it is SK's example).
> >
> > Robby
> >
> >
> > On Nov 24, 2007 3:07 PM, Benjamin L. Russell
> <dekudekuplex at yahoo.com> wrote:
> > > Yes, I see the problem now:  It is not clear how
> to
> > > perform mutual recursion in Clojure.
> > >
> > > Since there is no letrec, a combination of let,
> loop,
> > > and recur apparently must be used.  However, by
> > > definition, all three special forms bind
> sequentially,
> > > so it is not clear how to create mutually
> recursive
> > > definitions.  Without mutually recursive
> definitions,
> > > it does not seem possible to translate your
> procedure
> > > into Clojure.
> > >
> > > I checked all over their Web site and searched
> through
> > > their Googol group "Clojure" ( see
> > > http://groups.google.com/group/clojure ) for
> > > information on special forms allowing mutual
> > > recursion, but couldn't find anything.  In
> addition, I
> > > performed string searches on "Clojure" with both
> > > "mutual recursion" and "mutually recursive,"
> but,
> > > surprisingly, came up with nothing.  Strangely,
> nobody
> > > there has apparently asked about this yet.
> > >
> > > I'll probably need to ask on their Googol group
> about
> > > a workaround for mutual recursion; I can't find
> one
> > > anywhere in their online Clojure documentation. 
> If I
> > > come up with anything, I'll post it here.
> > >
> > > Benjamin L. Russell
> > >
> > > --- Shriram Krishnamurthi <sk at cs.brown.edu>
> wrote:
> > >
> > >
> > > > I don't know the recursive binding semantics
> of
> > > > Clojure (or, indeed,
> > > > anything else about it), but your translation
> > > >
> > > > (a) does different things for the init state
> than
> > > > for the more state
> > > >
> > > > (b) accumulates context for the transition
> from init
> > > > to more.
> > > >
> > > > So now suppose I wanted init and more to
> invoke one
> > > > another an
> > > > arbitrary number of times?
> > > >
> > > > Shriram
> > > >
> > >
> >
> > >
> _________________________________________________
> > >   For list-related administrative tasks:
> > >  
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> > >
> >
> 




Posted on the users mailing list.