Andrew Gwozdziewycz on 30 Jan 2008 14:14:30 -0800


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

Re: Graham released Arc

  • From: "Andrew Gwozdziewycz" <apgwoz@gmail.com>
  • To: philly-lambda@googlegroups.com
  • Subject: Re: Graham released Arc
  • Date: Wed, 30 Jan 2008 17:14:09 -0500
  • Authentication-results: mx.google.com; spf=pass (google.com: domain of apgwoz@gmail.com designates 209.85.198.189 as permitted sender) smtp.mail=apgwoz@gmail.com; dkim=pass (test mode) header.i=@gmail.com
  • 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:received:received:received-spf:authentication-results:received:dkim-signature:domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:reply-to:sender:precedence:x-google-loop:mailing-list:list-id:list-post:list-help:list-unsubscribe; bh=v/3iCwnckC0wuxTt3MhTXfA0ruEmqJ2DkaXDq8+BakM=; b=hR+6v1EBhd4QYdAD9bPhzyWiXOIWs8zMAvvS/JD+nnWFGfDxoXrpBsCKzzObDhMAv2Xhtg+ysEfFJoeyBJq4C/f/yLGhjjZbchBkAb2BTmqQJmHDBYOXaI9mQgLY0R9xSkWQpoLvD+wBCTl+pdsI7CFN+rvpgoQKZoi/3EME1+o=
  • Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=XDjNlPRhHKr/34Xhu0PdG+YMqTRggZl0vt3fbmz+578=; b=Id0hvGTYWarN/ByGu8i42lD8TlUySf/uu2J5KoCOTJFIIHXf2Y14/8aoyoZTOs0y8q7iw10CLxX5M7jIiaAijHzrhxxHDig3Yctt/Oca7UbzsHwLAf6anx0HWqCdeGRXSz1u20skqb7wtlUF6fFYY+NnlEYEODot20UMmFUncBs=
  • Mailing-list: list philly-lambda@googlegroups.com; contact philly-lambda-owner@googlegroups.com
  • Reply-to: philly-lambda@googlegroups.com
  • Sender: philly-lambda@googlegroups.com

On Jan 30, 2008 3:55 PM, Ed Watkeys <edw@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
apgwoz@gmail.com
http://www.apgwoz.com  | http://www.photub.com