Saturday, July 5, 2014
perl and forth
if you're look at the faq for blogging - i think it says somewhere no confessions.
certainly my confessions would be ( how easy is it to connect to a perl service ).
O I am sure that perl and forth are different --- yet I am a bit confused exactly
about how --- and can you break that thin gray line?
In fact is there a thin grey line?
I just think that if there is a thin grey line it something like ---
/// how is some old fashion notion --- a new fashion notion ///
like a cycling --- tensor - ( rotation ) ..
a link somewhere .
I have a lots to confess - so I won't.
Note: this somewhat anticpates itsy - vs parrot forth sometime in the future of this draft
which makes it almost daft.....
Forth on the Fifth
I was shooting for a forth on the fourth --- but, no way. I guess I might have to wait
for another " Fourth/fourth " ??????
Anyway, futzing quite along, I create this new object - which I need to futz with yet more
but just so I'm close to the fourth --- this is it:
\ sq-obj
object class pre-sq
method set-sq
method print-sq
method load-sq
class;
pre-sq class sq-obj
cell var offset
cell var index1-1
cell var index1-2
cell var index2-1
cell var index2-2
cell var square-no
how:
: set-sq ( n -- )
dup square-no ! 1 = if 0 offset ! 3 index1-1 ! 0 index1-2 ! 3 index2-1 ! 0 index2-2 ! else
square-no @ 2 = if 3 offset ! 3 index1-1 ! 0 index1-2 ! 3 index2-1 ! 0 index2-2 ! else
square-no @ 3 = if 6 offset ! 3 index1-1 ! 0 index1-2 ! 3 index2-1 ! 0 index2-2 ! else
square-no @ 4 = if 0 offset ! 6 index1-1 ! 3 index1-2 ! 3 index2-1 ! 0 index2-2 ! else
square-no @ 5 = if 3 offset ! 3 index1-1 ! 0 index1-2 ! 3 index2-1 ! 0 index2-2 ! else
\ bologna, ketchup, and lettuce
square-no @ 6 if 6 offset ! 3 index1-1 ! 0 index1-2 ! 3 index2-1 ! 0 index2-2 ! else
square-no @ 7 = if 0 offset ! 9 index1-1 ! 6 index1-2 ! 3 index2-1 ! 0 index2-2 ! else
square-no @ 8 = if 3 offset ! 9 index1-1 ! 6 index1-2 ! 3 index2-1 ! 0 index2-2 ! else
square-no @ 9 = if 6 offset ! 9 index1-1 ! 6 index1-2 ! 3 index2-1 ! 0 index2-2 ! then
then then then then then then then ;
: print-sq ( n -- ) set-sq
index1-1 @ index1-2 @ ?do i line-no-here !
index1-1 @ index1-2 @ ?do i column-calc2 + offset-here @ + c@ emit
loop loop ;
class;
\ end class
And it's also interesting to note that index2-1 is alway 3 and index2-2 is always 0 ???
Wednesday, July 2, 2014
Pattern Matching
I am not sure what I'm looking at -------
Now back to my collector obsessions ---
Here it is modified to use the oof - array and that does somewhat reduce the size and complexity ---
Now the following will demonstrate an interesting point ---- the process of removing errors - when I change course in what I'm doing --- In this case I had the clever idea about changing state because I was eliminating some other code ( specifically - nzp@ )
Anyone, one more pattern to match:
\-- find not contained in one array and put it into a second array
\-- for sudoku solver
\-- arraycollector.fs
include oofarray.fs
create vbp_ 9 cells allot
create vbpx_ 9 cells allot
42 42 42 42 42 42 42 42 42 9 int new[] 9 array : vbp
42 42 42 42 42 42 42 42 42 9 int new[] 9 array : vbpx
obj class precollector
method nextval@
method nextval!
method sv-next@
method sv-next!
method nv@
method nv!
method dump-collection
method nextval-prt
method reset-all
method sv-nextval
method reset-nextval
method check-unique
method store-input
method backup-current-vpb
method restore-current-vpb
method backup-current-vpbx
method restore-current-vpbx
method backup-current
method restore-current
method nextvalinc
method mode-set-1
method mode-init
method mode-get
method mode-get-prt
method mode-swt
method check-possible
method store-possible-lcl
method find-possible-lcl
method get-first
method set-this-collection-max
method get-this-collection-max
method process-empty-space
class;
precollector class arraycollector
cell var nextval
cell var sv-next
cell var inpv
cell var dupr
cell var lclvbp
cell var lclvbpx
cell var mode
cell var fnd
cell var collection-max
how:
: store-cell board line-no + col-no 9 * + nvp@ ! ;
: nextval@ nextval @ ;
: nextval! nextval ! ;
: nextvalinc nextval@ 1 + nextval! ;
: sv-next@ sv-next @ ;
: sv-next! sv-next ! ;
: nv! nextval@ 1 - vbp ! ;
: nv@ nextval@ 1 - vbp @ ;
: nvp! nextval@ 1 - vpbx ! ;
: nvp@ nextval@ 1 - vpbx @ ;
: reset-nextval sv-next@ nextval! ;
: sv-nextval nextval@ sv-next! ;
: nextval-prt cr s" nextval = " type nextval@ . ;
: reset-all 10 1 ?do i nextval! 42 nv! loop 1 nextval ! ;
: dump-collection sv-nextval 10 1 ?do i nextval! nv@ dup 10 < if . else emit then s" - " type loop reset-nextval ;
: check-unique inpv ! 0 dupr ! sv-nextval
10 1 ?do i nextval! nv@ inpv @ = if 1 dupr ! leave then loop
reset-nextval dupr @ ;
: get-first sv-nextval 1 nextval ! nv@ reset-nextval ;
: store-input check-unique 0 = if inpv @ nv! nextval@ 1 + nextval! then ;
: check-possible nextpval @ 1 - ;
: store-possible nvp! nextpval @ 1 + nextpval ! ;
: find-possible 0 fnd ! 10 1 ?do i dup check-val ! nextval! nv@ check-val @ = if 1 fnd ! then loop fnd @ 0 = if store-possible then ;
class;
Tuesday, July 1, 2014
Dipsy Doodle
This is actually about array using oof ---
or maybe oof arrays --- technically I'm not sure ---
for historical reference, this could be helpful -----
Covering Tommy Dorsey's 1937 hit, Larry Clinton & His Orchestra perform the titular big-band classic in the soundie Dipsy Doodle (1943). This number was often covered, notably by Ella Fitzgerald with Chick Webb's orchestra, & even by Bill Haley & the Comets, besides being goofed up by Homer & Jethro.
from : http://www.weirdwildrealm.com/f-larry-clinton.html
From some where - or maybe here - I acquired on oof array --- what I'm talking about :
https://github.com/BlastarIndia/Blastarix/blob/master/gforth-0.7.2/oofsampl.fs
and I created this " beasty " :
/ oofarray.fs
include oof.fs
: i! postpone ! ; immediate
: i@ postpone @ ; immediate
object class data \ abstract data class
cell var ref \ reference counter
method ! method @ method .
method null method atom? method #
how: : atom? ( -- flag ) true ;
: # ( -- n ) 0 ;
: null ( -- addr ) new ;
class;
\ Data structures: int 30apr93py
data class int
cell var value
how: : ! value i! ;
: @ value i@ ;
: . @ 0 .r ;
: init ( data -- ) ! ;
: dispose -1 ref +!
ref i@ 0> 0= IF super dispose THEN ;
: null 0 new ;
class;
\ Data sturctures: array 30apr93py
data class array
data [] container
cell var range
how: : ! container ! ;
: @ container @ ;
: . [char] [
# 0 ?DO emit I container . [char] , LOOP drop ." ]" ;
: init ( data n -- ) range i! bind container ;
: dispose -1 ref +! ref i@ 0> 0=
IF # 0 ?DO I container dispose LOOP
super dispose THEN ;
: null nil 0 new ;
: # range i@ ;
: atom? false ;
class;
\
\1 3 5 7 9 5 int new[] 5 array : lotus ok
\lotus . [1,3,5,7,9] ok
\1 lotus @ . 3 ok
\cr 5 1 lotus ! lotus .
or maybe oof arrays --- technically I'm not sure ---
for historical reference, this could be helpful -----
Covering Tommy Dorsey's 1937 hit, Larry Clinton & His Orchestra perform the titular big-band classic in the soundie Dipsy Doodle (1943). This number was often covered, notably by Ella Fitzgerald with Chick Webb's orchestra, & even by Bill Haley & the Comets, besides being goofed up by Homer & Jethro.
from : http://www.weirdwildrealm.com/f-larry-clinton.html
From some where - or maybe here - I acquired on oof array --- what I'm talking about :
https://github.com/BlastarIndia/Blastarix/blob/master/gforth-0.7.2/oofsampl.fs
and I created this " beasty " :
/ oofarray.fs
include oof.fs
: i! postpone ! ; immediate
: i@ postpone @ ; immediate
object class data \ abstract data class
cell var ref \ reference counter
method ! method @ method .
method null method atom? method #
how: : atom? ( -- flag ) true ;
: # ( -- n ) 0 ;
: null ( -- addr ) new ;
class;
\ Data structures: int 30apr93py
data class int
cell var value
how: : ! value i! ;
: @ value i@ ;
: . @ 0 .r ;
: init ( data -- ) ! ;
: dispose -1 ref +!
ref i@ 0> 0= IF super dispose THEN ;
: null 0 new ;
class;
\ Data sturctures: array 30apr93py
data class array
data [] container
cell var range
how: : ! container ! ;
: @ container @ ;
: . [char] [
# 0 ?DO emit I container . [char] , LOOP drop ." ]" ;
: init ( data n -- ) range i! bind container ;
: dispose -1 ref +! ref i@ 0> 0=
IF # 0 ?DO I container dispose LOOP
super dispose THEN ;
: null nil 0 new ;
: # range i@ ;
: atom? false ;
class;
\
\1 3 5 7 9 5 int new[] 5 array : lotus ok
\lotus . [1,3,5,7,9] ok
\1 lotus @ . 3 ok
\cr 5 1 lotus ! lotus .
more latter - on this --- and where it's going ----
Subscribe to:
Posts (Atom)
.jpg)

