I am talking about explaining the J lines step by step
I do know what moo does.
It is a mastermind where J makes the guesses.
moo 6$10 would start it.
It is a very ingenious and it would be very interesting for beginners in J
to have it explained.
I guess this one page of code would need several pages of explanations and I
think it would be very much wort it.
2008/1/8, Raul Miller <[EMAIL PROTECTED]>:
>
> On 1/8/08, Björn Helgason <[EMAIL PROTECTED]> wrote:
> > It would be really interesting to see Rogers moo functionality explained
> > line by line operation by operation
> >
> > load 'misc' NB. needs "prompt" from "misc"
> >
> > display=: 1!:2&2
> >
> > NB. univ =: (*./@(~:"1) # ]) @ (#: i.@(*/))
> > univ =: #: i.@(*/)
> >
> > guess =: [EMAIL PROTECTED] { ]
> > score =: ; prompt@(,&' ')@":
> > solved =: (('b' $~ [EMAIL PROTECTED]) -: ])&>/@[
> > bull =: +/@('b'&=)@(>@{:@[) = >@[EMAIL PROTECTED] +/@(="1) ]
> > NB. bc =: #@(>@{:@[) = ] +/@e."1 >@[EMAIL PROTECTED]
> > bc =: #@(>@{:@[) = ] ([ +/@:([ <. -~) [EMAIL PROTECTED] {. ])&(#/.~)"1
> > ],"1 >@[EMAIL PROTECTED]
> > prune =: ((bull *. bc) # ]) ` (''"_) @. solved
> >
> > s0 =: display@('no choices left'&[)
> > s1 =: display@('one choice left; it must be '&,)@":@,
> > sn =: display@(,&' choices left')@":@#
> > state =: [EMAIL PROTECTED](0 1 i. #) ` ] @. ('' -: ])
> >
> > moo1 =: ([state)@([EMAIL PROTECTED] prune ])^:(1&<@#)
> > moo =: moo1^:_ @ univ
>
> Hmm... I do not remember this code, and do not remember
> its purpose, nor its domain. And, purpose and domain are
> crucial for understanding code.
>
> However, I recognize univ as the odometer function (which is
> described in the J wiki). For example, if I wanted all possibilities
> for lists with 2 options for the first choice, 3 for the second and 2
> for the third, I might use:
> univ 2 3 2
> 0 0 0
> 0 0 1
> 0 1 0
> 0 1 1
> 0 2 0
> 0 2 1
> 1 0 0
> 1 0 1
> 1 1 0
> 1 1 1
> 1 2 0
> 1 2 1
>
> So that tells me the domain.
>
> This suggests that moo is probably a guessing game. And a google
> search for moo guessing game finds me
>
> http://publib.boulder.ibm.com/infocenter/systems/topic/com.ibm.aix.cmds/doc/aixcmds3/moo.htm
>
> This tells me that "bulls" means guessed numbers that are
> correct in value and in the correct position, while "cows" means
> guessed numbers that are correct in value but in the wrong
> position.
>
> But here I get stuck -- I do not know the "domain" expected at the
> prompt, and no hints jump out at me.
>
> Anyways, I am reluctant to spend more time reverse engineering
> this program, I would prefer a few senteces of documentation.
>
> Thanks,
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
Björn Helgason, Verkfræðingur
Fugl&Fiskur ehf, Þerneyjarsund 23, Box 127
801 Grímsnes ,t-póst: [EMAIL PROTECTED]
Skype: gosiminn, gsm: +3546985532
Landslags og skrúðgarðagerð, gröfuþjónusta
http://groups.google.com/group/J-Programming
Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
góður kennari getur stigið á tær án þess að glansinn fari af skónum
/|_ .-----------------------------------.
,' .\ / | Með léttri lund verður |
,--' _,' | Dagurinn í dag |
/ / | Enn betri en gærdagurinn |
( -. | `-----------------------------------'
| ) | (\_ _/)
(`-. '--.) (='.'=)
`. )----' (")_(")
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm