Search the web
Sign In
New User? Sign Up
concatenative · Discuss the concatenative variety of computer languages: Joy, Forth, Postscript
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Please ignore   Message List  
Reply | Forward Message #1408 of 4643 |
Re: [stack] Patterns, recursion combinators and a programming challenge

On Fri, 2003-05-02 at 14:15, Nick Forde wrote:
> So my best solution is still:
>
> DEFINE foo ==
> [+] cons [infra dup rest cons] cons
> [dupd swons swons].
>
> Are there no other takers? There must be a better Joy implementation
> than this. Also the first call to this function only initialises the
> accumulator, whereas it should actually execute the first accumulate
> operation.

The problem statement is still opaque to me so I've probably
misunderstood. Below is a solution (?) in Monkey (my Joy-alike) but the
Joy version (untested) would be:

DEFINE foo ==
[ + foo ] cons .

Or is explicit recursion not allowed?

----snip--snip----

<< -----------------------
Accumulator generators.
----------------------- >>

module main provides main .
uses io .

<< Entry point of program. >>
main ==
{{
3 accgen << First invocation >>
dup . nl << Show result (accum=3). >>

1 swap i << 2nd invocation. >>
dup . nl << Show result (accum=4). >>

dup << Keep a copy of this accumulator function. >>

5 swap i << Accumlate again. >>
dup . 10 emit << Show result (accum=9). >>

drop << Drop the last accumulator, revery to
previously saved one. >>

2 swap i << Acuum. again. >>
dup . 10 emit << Show result (accum=6). >>
}}

<< The generator. >>
accgen ==
{{
[ + accgen ] cons programise
}}

----snip--snip----

Output is:

[my@upstairs MONKEY]$ ./monkey accgen.mmod
Creating stub module definition for "main".
Creating stub module definition for "io".
Will scan "io".
Creating stub module definition for "control".
Will scan "control".
{ 3 + accgen }
{ 4 + accgen }
{ 9 + accgen }
{ 6 + accgen }






Fri May 2, 2003 3:28 pm

venusian_1999
Offline Offline
Send Email Send Email

Forward
Message #1408 of 4643 |
Expand Messages Author Sort by Date

Sorry folks, I broke all my mail files and need something to reply to. Do not reply to this (unless you are me - if you know what I mean). - Manfred...
phimvt@...
phimvt
Offline Send Email
Apr 23, 2003
8:00 am

Sorry about the mess. Thank you all for the help with the "#!" flag. On the web page in j09imp.html ("The current implementation" Section 5 "Initating a Joy ...
phimvt@...
phimvt
Offline Send Email
Apr 23, 2003
8:35 am

Thanks for the question, Nick, it prompted me to think long and hard. Part of the answer is this draft for two new questions for the Further FAQ, FFAQ (visible...
phimvt@...
phimvt
Offline Send Email
Apr 24, 2003
6:33 am

Manfred, Thanks for your detailed response. I did a little web searching and came across one attempt at formalising recursive patterns in a similar way to the...
Nick Forde
nickf42uk
Offline Send Email
Apr 24, 2003
2:33 pm

... Thanks for that. My response to the pattern movement had been tepid until now, but after your mail I might well have another look. ... I was intrigued by...
phimvt@...
phimvt
Offline Send Email
Apr 28, 2003
3:15 am

... When I first read about design patterns I wasn't particularly impressed as they didn't really give me any new insights into OO design. I'd encountered many...
Nick Forde
nickf42uk
Offline Send Email
Apr 28, 2003
12:34 pm

... Yes, that is the conclusion I reached when writing my previous note. The "structured flow of control" patterns IF, WHILE, REPEAT, CASE LOOP-and-a-half...
phimvt@...
phimvt
Offline Send Email
May 2, 2003
7:10 am

On Mon, 28 Apr 2003, Nick Forde wrote: [..] ... I found the specification of the problem quite inscrutable, and eventually understood it only when I read some...
phimvt@...
phimvt
Offline Send Email
May 2, 2003
9:11 am

... Yes, me too. Looking at some of the other solutions I now think my initial attempt was over engineered. ... Looking at some of the other solutions the...
Nick Forde
nickf42uk
Offline Send Email
May 2, 2003
9:35 am

... Here's a slightly better description of the problem: http://www.paulgraham.com/accgensub.html 1. Takes, and returns functions that take, exactly one...
Nick Forde
nickf42uk
Offline Send Email
May 2, 2003
1:15 pm

... The problem statement is still opaque to me so I've probably misunderstood. Below is a solution (?) in Monkey (my Joy-alike) but the Joy version...
Martin Young
venusian_1999
Offline Send Email
May 2, 2003
3:31 pm

Hi Martin, ... Nice! I think this _is_ a valid solution. I've also just noticed that my solution returns i incremented by n rather than n incremented by i....
Nick Forde
nickf42uk
Offline Send Email
May 2, 2003
4:36 pm

On Fri, 2 May 2003, Nick Forde wrote: [.. a propos solutions to the "accumulator challenge" ..] ... No, I think you were exactly right. Over the weekend I did...
phimvt@...
phimvt
Offline Send Email
May 5, 2003
7:21 am

On Thu, 24 Apr 2003 phimvt@... wrote: [...] ... [...] ... 07-MAY On the Joy page, NEW: A (longish) note on nested recursion, several...
phimvt@...
phimvt
Offline Send Email
May 7, 2003
10:26 am

... Very cool stuff. I am now beginning to play around with a Joy implementation in Scheme. The current C implementation is usable, but it is not beautiful...
John Cowan
johnwcowan
Online Now Send Email
May 8, 2003
9:07 pm

On Thu, 8 May 2003, John Cowan wrote: [...] ... Alas, yes. I have on occasions thought about a cleaner and more flexible implementation, but it is all rather...
phimvt@...
phimvt
Offline Send Email
May 9, 2003
9:46 am

... Someone sent me an executable, dated 5 June 2001, so it does not have the latest fixes. The URL is http://www.ccil.org/~cowan/joy1.exe ; feel free to copy...
John Cowan
johnwcowan
Online Now Send Email
May 9, 2003
2:21 pm

... I agree. I'm still getting my head around it! ... Great. A Scheme implementation would be much more elegant than the current C interpreter, although...
Nick Forde
nickf42uk
Offline Send Email
May 9, 2003
6:30 pm

... Well, it depends on your environment: Unixes tend to come with gcc but not Scheme, so there is that hurdle to get over; still, the RPM package and the...
John Cowan
johnwcowan
Online Now Send Email
May 9, 2003
9:28 pm

... to C ... more ... but not ... and ... [snip] Have you checked out Bigloo Scheme? I believe it is compiled directly into C. It's free, has .rpm's for...
John Hodge
cyfododd
Offline Send Email
May 9, 2003
11:24 pm

... Excellent point. When I get the implemention done in Petite, I'll grab Bigloo and generate myself some C. ... Exactly what I have in mind: (j 32 45 +) ...
John Cowan
johnwcowan
Online Now Send Email
May 10, 2003
12:29 am

... grab ... that ... to ... Great! The chapter on embedding Prolog is toward the back of the book ;) Amazingly, Graham implements the entire language in a...
John Hodge
cyfododd
Offline Send Email
May 10, 2003
1:31 am

... I sure don't see any way to do it using only R5RS hygienic macros. So far my only deviation from R5RS is that in the Chez implementation symbols have...
John Cowan
johnwcowan
Online Now Send Email
May 10, 2003
4:03 am

... [snip] ... Ah, finally something I'm qualified to speak about around here ;) (1996) http://www.cs.indiana.edu/scheme-repository/imp/siod.html (1997)...
Ben
gnomon027
Offline Send Email
May 10, 2003
12:50 am

thanks john. finally, i'm able to actually run joy ... ... From: "John Cowan" <cowan@...> To: <concatenative@yahoogroups.com> Sent: Friday, May 09, 2003...
Stevan Apter
sa@...
Send Email
May 9, 2003
4:07 pm

... know ... Pretty sure the most up-to-date page is http://people.delphiforums.com/gjc/siod.html. Another Scheme implementation in a similar vein is Gauche....
Steven Shaw
steshaw
Offline Send Email
May 10, 2003
4:23 am

... Ah, thanks. As someone else said, not even R4RS here. ... Excellent. ... Even better! -- Is a chair finely made tragic or comic? Is the John...
John Cowan
johnwcowan
Online Now Send Email
May 10, 2003
4:58 am

... It was pointed out to me that the top-of-page banner and the botton-of-page banner make some of my web pages hard to read. History: For years I have been...
phimvt@...
phimvt
Offline Send Email
May 9, 2003
6:36 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help