Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #21872

Re: Injecting some activity through "questions" (DSLs)

From John Harris <niam@jghnorth.org.uk.invalid>
Newsgroups comp.lang.javascript
Subject Re: Injecting some activity through "questions" (DSLs)
Date 2013-11-03 11:23 +0000
Organization A noiseless patient Spider
Message-ID <lhcc79h62b9vl6jgnu13pgvmj5nnnpfpjs@4ax.com> (permalink)
References <2a650b44-7c6b-4478-810d-9b091bb78559@googlegroups.com>

Show all headers | View raw


On Fri, 1 Nov 2013 21:06:41 -0700 (PDT), "Michael Haufe (TNO)"
<tno@thenewobjective.com> wrote:

>Since there have been complaints about lack of questions and activity in the group, I've decided to ask a question once in awhile to hopefully spark some more activity. These will probably be questions I already know the answer to or something which is in the realm of opinion/style and a point of conflict in the JS community in general. On the former kind of questions I'll feign ignorance in order to draw out some hopefully useful discussions and aspects. So if you're willing to play along, here is my first question:

I see you've been admonished for not having a longer Subject.


>I have a <canvas/> element upon which I draw shapes and lines. To abstract away the dirty details, I've created a small language with which I use to draw the desired shapes:
>
>F: Draw Forward
>f: Move Forward
>[: Push State
>]: Pop State
>-: Rotate Left
>+: Rotate Right

  <snip>
>    rules: {
>        "F": "+F--F+"
>    }

  <snip>
>Currently my program works by initially performing the replacements and expanding the drawing commands out as far as necessary before executing the final string (which as you've seen, can be quite large).
>
>How would you approach this problem and prevent the exponential expansion of the string while still being able to execute the drawing rules?

That explosion problem can be avoided by enhancing your turtle
graphics language to include subroutines, aka functions, and function
calls.

Where F expands into +F--F+ you have an F-call to a function that can
do a further F-call without making a mess of it. Your language has to
have a way of defining functions and to test whether the depth limit
has been reached.

The length of the string is now constant whatever depth is needed. 

But not the time needed to draw the exponentially increasing number of
pixels :-(

  John

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Injecting some activity through "questions" (DSLs) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-11-01 21:06 -0700
  Re: Injecting some activity through "questions" (DSLs) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-11-02 20:15 +0000
    Re: Injecting some activity through "questions" (DSLs) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-11-03 15:30 -0800
      Re: Injecting some activity through "questions" (DSLs) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-11-04 02:06 +0000
        Re: Injecting some activity through "questions" (DSLs) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-11-11 13:11 -0800
          Re: Injecting some activity through "questions" (DSLs) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-11-11 21:55 +0000
  L-system construction of Lévy C curves (was: Injecting some activity through "questions" (DSLs)) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-02 21:31 +0100
    Re: L-system construction of Lévy C curves (was: Injecting some activity through "questions" (DSLs)) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-11-03 15:38 -0800
      Re: L-system construction of Lévy C curves Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-04 03:12 +0100
        Re: L-system construction of Lévy C curves "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-11-03 19:17 -0800
  Re: Injecting some activity through "questions" (DSLs) John Harris <niam@jghnorth.org.uk.invalid> - 2013-11-03 11:23 +0000
    Re: Injecting some activity through "questions" (DSLs) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-11-03 12:43 +0000
    Re: Injecting some activity through "questions" (DSLs) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-11-03 15:41 -0800

csiph-web