Raul,  Both  F_Words and  f  deal with characters.  However when you get to
plot you need numbers.

    '0'=_1{::F_Words 8
1 0 1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 1 0 1
   '0'=_1{::f 8
1 0 1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 1 0 1
   
Would it be possible to write a recursive function that would get your list
directly as numbers.

   'A B'=:1 `0
   ]A
1
   ]B
0
   ]A=:B,A
0 1
   ]B=:A,B
0 1 0
   ]A=:B,A
0 1 0 0 1
   ]B=:A,B
0 1 0 0 1 0 1 0
   ]A=:B,A
0 1 0 0 1 0 1 0 0 1 0 0 1
   ]B=:A,B
0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 1 0 1 0
      
      
   (-.0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 1 0 1 0)-:'0'=_1{::f 8
1
   
I'm not yet very good at doing that yet.

Linda



-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Linda Alvord
Sent: Thursday, May 29, 2014 11:45 PM
To: [email protected]
Subject: Re: [Jprogramming] Turtle graphics, Gaussian integers and
Mechanical action...

I learned a lot untangling F_Words.

require 'plot'
   
   F_Words=:(, <@;@:{~&_1 _2)@]^:(2 -~ [)&('1';'0')
   
   NB.plot }:+/\ 0,*/\(^~ 0j_1 0j1 $~ #)'0'=_1{::F_Words 20
   
   F_Words 5
--T-T--T---T-----┐
│1│0│01│010│01001│
L-+-+--+---+------
   
   
   A=:_1 _2
   
   B=:('1';'0')
   
   f=: 13 :'(y([:(,_1 _2 (([:([:<;){)~)~] )])^:(2-~[) (''1'';''0''))'
   
   f 5 
--T-T--T---T-----┐
│1│0│01│010│01001│
L-+-+--+---+------
   
   F_Words
(, <@;@:{~&_1 _2)@]^:(2 -~ [)&('1';'0')
   
   5!:4 <'F_Words'
                            -- ,                           
                            │                          -- <
                      ------+                    -- @ -+- ;
                      │     │     -- ~ ----- @: -+- {      
                -- @ -+     L- & -+- _1 _2                 
                │     L- ]                                 
      -- ^: ----+                                          
      │         │     -- 2                                 
-- & -+         L-----+- ~ --- -                           
      │               L- [                                 
      L- '1';'0'                                           
   
   f
('1';'0') ([: (, (_1 _2 ([: ([: < ;) {)~~ ])) ])^:(2 -~ [)~ ]
   
   5!:4 <'f'
  -- '1';'0'                                             
  │                  -- [:                               
  │                  │     -- ,                          
  │                  │     │   -- _1 _2                  
  │                  +-----+   │               -- [:     
  │                  │     │   │               │    -- [:
  │                --+     L---+- ~ ----- ~ ---+----+- < 
  │                │ │         │               │    L- ; 
--+                │ │         │               L- {      
  │                │ │         L- ]                      
  +- ~ ------- ^: -+ L- ]                                
  │                │                                     
  │                │ -- 2                                
  │                L-+- ~ --- -                          
  │                  L- [                                
  L- ]                                                   
   
   plot }:+/\ 0,*/\(^~ 0j_1 0j1 $~ #)'0'=_1{:: f 20
   

Linda

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Raul Miller
Sent: Sunday, May 18, 2014 2:07 PM
To: Programming forum
Subject: [Jprogramming] Turtle graphics, Gaussian integers and Mechanical
action...

I added a rosettacode entry, yesterday, which was inspired by Brian
Schott's turtle graphics work:
http://rosettacode.org/wiki/Fibonacci_word/fractal#J

Repeating the code here:

F_Words=: (,<@;@:{~&_1 _2)@]^:(2-~[)&('1';'0')
require 'plot'
plot }:+/\ 0,*/\(^~ 0j_1 0j1 $~ #)'0'=_1{::F_Words 20

This uses complex number arithmetic to achieve a sort of simplified "turtle
graphics" system - basically just drawing a parametric curve constructed of
unit length line segments with a heading which is a unit-length complex
integer.

And then today, I saw this:

http://507movements.com

This is a book from 1868, that someone must have taken years to write,
originally. And, now Matt Keveney is working through it, translating the
original woodcut images to code driving html5 canvas rendered animations.
(This also looks like it took significant time to write, though the code
looks like it might have been obfuscated and I do not know what tools and
source material he used to build it out.)

This is obviously considerably more complex than my little bit of code
(which Cliff Reiter probably has already written and discarded several
times and maybe even forgotten about), but perhaps this sort of thing can
inspire someone else's work?

(But it's a lot simpler than what people building airplanes deal with. I
think...)

Thanks,

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to