Ed Watkeys on 31 Jan 2008 04:40:48 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Graham released Arc

  • From: Ed Watkeys <edw@poseur.com>
  • To: Philly Lambda <philly-lambda@googlegroups.com>
  • Subject: Re: Graham released Arc
  • Date: Thu, 31 Jan 2008 04:40:40 -0800 (PST)
  • Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to:mime-version:message-id:date:received:in-reply-to:x-ip:references:user-agent:x-http-useragent:subject:from:to:content-type:content-transfer-encoding:reply-to:sender:precedence:x-google-loop:mailing-list:list-id:list-post:list-help:list-unsubscribe; bh=pnQWzqf7jsMXJcNxwuxhLzOmNSCm3V1LYayMP1Ihcxs=; b=vKeCgjW12ROnwRMRjOy1Z1/nGxiyFuhIBG2AYN+rVcAopwAMNwhk8znRu1fnNF3ufKPwdXdzDa3CAjr6oTGfJlXcxv1GKRHPUV290ePXdK7HStbjurB9lVwUyhgmfmAFbrBKVHfL9qIq7vJ8gTCnGKb4AbLhvivaTAfJEZ3tsg0=
  • Mailing-list: list philly-lambda@googlegroups.com; contact philly-lambda-owner@googlegroups.com
  • Reply-to: philly-lambda@googlegroups.com
  • Sender: philly-lambda@googlegroups.com
  • User-agent: G2/1.0

A couple candidates:

* Collections are functions.
* Automatic composition and negation of functions.
  E.g. foo:~bar ==> (fn (x) (foo (no (bar x))))

Ed

On Jan 30, 5:14 pm, "Andrew Gwozdziewycz" <apg...@gmail.com> wrote:
> On Jan 30, 2008 3:55 PM, Ed Watkeys <e...@poseur.com> wrote:
>
>
>
>
>
> > There are a couple things that I want to see idiomatic code for. Most
> > importantly is looping: In Scheme, you could write a procedure in to
> > compute the Nth fib thusly:
>
> > (define (fib n)
> >   (let loop ((a 0) (b 1) (n n))
> >     (if (zero? n)
> >         a
> >         (loop b (+ a b) (- n 1)))))
>
> > But in Arc? There's no named-let, no letrec, so I came up with this:
>
> > (def fib (n)
> >      (with (a 0 b 1)
> >            (for i 1 n
> >                 (let old-a a
> >                   (= a b)
> >                   (= b (+ old-a b))))
> >           a))
>
> > What a mess! Does Arc have nested definitions? Let me check...
>
> > (def fib (n)
> >      (def iter (n a b)
> >           (if (is n 0)
> >               a
> >               (iter (-- n) b (+ a b))))
> >      (iter n 0 1))
>
> > Yes, that works, sort of: ITER gets defined in the global scope. So a
> > separate helper function is called for...
>
> > (def fib-helper (n a b)
> >   (if (is n 0) a (fib-helper (-- n) b (+ a b))))
>
> > (def fib (n)
> >   (fib-helper (n 0 1)))
>
> > That first version also does a lot of mutation. Hmm...
>
> > Andrew, regarding your comment on the nature of the code, I hear you,
> > but I like to take the plunge into a language and try to appreciate it
> > on it's own terms for a while and see how things go. It could wind up
> > sucking, but there's enough interesting stuff to merit swishing the
> > Kool-Aid around in my mouth for a bit.
>
> I'm not saying that I won't peck around with it... (I've already been
> procrastinating at work to do so) but, I don't yet see anything that
> makes my mouth drop and say, "duh, why haven't I been doing it this
> way all along!"
>
> arc> (= x 1)
> 1
> arc> (mac foo (y) (+ y x))
> *** redefining foo
> #3(tagged mac #<procedure>)
> arc> (foo 2)
> 3
> arc> (with (x 99) (foo 2))
> 3
> arc>
> arc> ^Cuser break
>
> > (define x 1)
> > (define-syntax foo
>
> (syntax-rules ()
>   ((_ y) (+ x y))))
>
> > (foo 2)
> 3
> > (let ((x 99)) (foo 2))
> 3
>
> > (require (lib "defmacro.ss"))
> > (define-macro (foo y)
> `(+ x ,y))
> > (foo 2)
> 3
> > (let ((x 99)) (foo 2))
> 101
>
> --
> Andrew Gwozdziewycz
> apg...@gmail.comhttp://www.apgwoz.com ;|http://www.photub.com