I pasted the line together so 'o' looked ok. It was where the line broke in my
message. I tried it a couple of times with similar results.
toss =: (dice =: (6 6 6#:12 145 157 185 197 215)
<@:{"1 2 (#:i.6){'o') {~ 2 10 ?@$ 6:
|spelling error
| toss =: (dice =: (6 6 6#:12 145 157 185 197 215)
<@:{"1 2 (#:i.6){'o') {~ 2 10 ?@$ 6:
| ^
If this works, when you type toss '' aren't you really using a monadic verb ?
So far no one seems to be able to create an expression that will produce two
different results consecutively.
I think I'll be holding a fistful of APL symbols even though I'm not
responsible for creating them.
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Henry Rich
Sent: Thursday, December 01, 2011 7:01 PM
To: Programming forum
Subject: Re: [Jprogramming] Turkey Roll - Challenge 2 Rich Text
toss =: (dice =: (6 6 6#:12 145 157 185 197 215) <@:{"1 2 (#:i.6){'
o') {~ 2 10 ?@$ 6:
toss''
+---+---+---+---+---+---+---+---+---+---+
|o o|o o|o |o o|o o|o |o | |o o|o o|
| | o | |o o| o | o | | o | | |
|o o|o o| o|o o|o o| o| o| |o o|o o|
+---+---+---+---+---+---+---+---+---+---+
|o o|o |o o|o |o |o o|o |o o| |o o|
|o o| o |o o| o | |o o| |o o| o |o o|
|o o| o|o o| o| o|o o| o|o o| |o o|
+---+---+---+---+---+---+---+---+---+---+
Henry Rich, whose @ will be pried from his cold dead fingers
On 12/1/2011 6:25 PM, Linda Alvord wrote:
> I was curious to see if you would get a new toss each time if toss{dice was
> a verb. It would not run syntax error scripted. You got the same result
> twice like both Ric and I did. So if you change a few names around, see if
> you can define toss 6 as a monadic form of toss to produce different results
> when repeated.
>
> one =: ' ',' o ',:' '
> two =: 'o ',' ',:' o'
> three =: 'o ',' o ',:' o'
> four =: 'o o',' ',:'o o'
> five =: 'o o',' o ',:'o o'
> six =: 'o o','o o',:'o o'
> ]dice =: one;two;three;four;five;six
> ]ten =: [: ? (2 10 $ 6)"_ NB. ten tosses of two dice
> toss =: ten''
> 5 4 5 2 4 3 0 2 4 2
> 2 1 4 4 3 2 0 3 3 3
> tossscripted=:toss { dice
> ]sums =: 2 + +/ toss
> 9 7 11 8 9 7 2 7 9 7
> fd =: [: /:~ ~. ,. [: +/"1 ~. =/ ]
> fd sums
> 2 1
> 7 4
> 8 1
> 9 3
> 11 1
> 4!:0 'dice';'toss';'sums';'fd'
> 0 0 0 3
> dice
> ten
> tossscripted NB. toss changed to a function.
> tossscripted
> toss NB. this is c
> sums
> fd sums NB. this is fd sums
> 0 0 0 3 = 4!:0 ;:'dice toss c fd'
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Kip Murray
> Sent: Thursday, December 01, 2011 9:46 AM
> To: Programming forum
> Subject: Re: [Jprogramming] Turkey Roll - Challenge 2 Rich Text
>
> Not precisely what you asked for, Linda, but equivalent:
>
> one =: ' ',' o ',:' '
> two =: 'o ',' ',:' o'
> three =: 'o ',' o ',:' o'
> four =: 'o o',' ',:'o o'
> five =: 'o o',' o ',:'o o'
> six =: 'o o','o o',:'o o'
>
> ]dice =: one;two;three;four;five;six
> +---+---+---+---+---+---+
> | |o |o |o o|o o|o o|
> | o | | o | | o |o o|
> | | o| o|o o|o o|o o|
> +---+---+---+---+---+---+
>
> ten =: [: ? (2 10 $ 6)"_ NB. ten tosses of two dice
>
> ]toss =: ten''
> 5 4 5 2 4 3 0 2 4 2
> 2 1 4 4 3 2 0 3 3 3
>
> toss { dice
> +---+---+---+---+---+---+---+---+---+---+
> |o o|o o|o o|o |o o|o o| |o |o o|o |
> |o o| o |o o| o | o | | o | o | o | o |
> |o o|o o|o o| o|o o|o o| | o|o o| o|
> +---+---+---+---+---+---+---+---+---+---+
> |o |o |o o|o o|o o|o | |o o|o o|o o|
> | o | | o | o | | o | o | | | |
> | o| o|o o|o o|o o| o| |o o|o o|o o|
> +---+---+---+---+---+---+---+---+---+---+
>
> ]sums =: 2 + +/ toss
> 9 7 11 8 9 7 2 7 9 7
>
> fd =: [: /:~ ~. ,. [: +/"1 ~. =/ ]
>
> fd sums
> 2 1
> 7 4
> 8 1
> 9 3
> 11 1
>
> 4!:0 'dice';'toss';'sums';'fd'
> 0 0 0 3
>
>
> On 11/26/2011 3:14 AM, Linda Alvord wrote:
>> Version 3 Rich Text
>>
>> Version 2 Plain text. How can I make the graphic symbols look good?
>>
>> PLEASE DO NOT REPLY BEFORE December I, 2011 at 12:00 am EST !
>>
>> The turkey roll challenge, named in honor of the Thanksgiving Day
>> holiday, focuses on the verb roll or ? with one argument.
>>
>> Create two nouns and a verb that will generate the following results.
>>
>> dice
>> ----T---T---T---T---T---┐
>> │ │o │o │o o│o o│o o│
>> │ o │ │ o │ │ o │o o│
>> │ │ o│ o│o o│o o│o o│
>> L---+---+---+---+---+----
>>
>> toss
>> ----T-T---T-T---T-T---T-T---T-T---T-T---T-T---T-T---T-T---┐
>> │o │ │o │ │o o│ │o o│ │o │ │o │ │ │ │o o│ │o │ │o │
>> │ o │ │ │ │ │ │ o │ │ o │ │ │ │ o │ │ │ │ o │ │ │
>> │ o│ │ o│ │o o│ │o o│ │ o│ │ o│ │ │ │o o│ │ o│ │ o│
>> +---+-+---+-+---+-+---+-+---+-+---+-+---+-+---+-+---+-+---+
>> │o │ │o │ │o │ │o │ │o o│ │ │ │ │ │o o│ │o o│ │ │
>> │ │ │ o │ │ │ │ │ │ o │ │ o │ │ o │ │ │ │o o│ │ o │
>> │ o│ │ o│ │ o│ │ o│ │o o│ │ │ │ │ │o o│ │o o│ │ │
>> L---+-+---+-+---+-+---+-+---+-+---+-+---+-+---+-+---+-+----
>> toss
>> ----T-T---T-T---T-T---T-T---T-T---T-T---T-T---T-T---T-T---┐
>> │o │ │o │ │o o│ │o o│ │o │ │o │ │ │ │o o│ │o │ │o │
>> │ o │ │ │ │ │ │ o │ │ o │ │ │ │ o │ │ │ │ o │ │ │
>> │ o│ │ o│ │o o│ │o o│ │ o│ │ o│ │ │ │o o│ │ o│ │ o│
>> +---+-+---+-+---+-+---+-+---+-+---+-+---+-+---+-+---+-+---+
>> │o │ │o │ │o │ │o │ │o o│ │ │ │ │ │o o│ │o o│ │ │
>> │ │ │ o │ │ │ │ │ │ o │ │ o │ │ o │ │ │ │o o│ │ o │
>> │ o│ │ o│ │ o│ │ o│ │o o│ │ │ │ │ │o o│ │o o│ │ │
>> L---+-+---+-+---+-+---+-+---+-+---+-+---+-+---+-+---+-+----
>>
>> c=:3 8 7 12 9 8 9 7 4 12 NB. The list c is the sums of the
>> NB. second toss of ten dice
>> fd c
>> 3 1 NB. A frequency distribution of the
>> 4 1 NB. ten tosses
>> 7 2
>> 8 2
>> 9 2
>> 12 2
>>
>> 4!:0 'dice';'toss';'c';'fd'
>> 0 0 0 3 NB. 0 for nouns, 3 for verbs
>>
>>
>> Some rules and hints:
>>
>> Write all verbs and nouns without @ . You can use several nouns and
>> verbs to make a final noun or verb. Here are some things about roll.
>>
>> r=: 13 :'?y'
>> r
>> ?
>> r 4
>> 3
>> r 4
>> 2
>> s=: 13 :'r 3 4$y'
>> s
>> [: r 3 4 $ ]
>> s 5
>> 3 3 3 2
>> 3 2 3 4
>> 2 4 0 4
>> s 5
>> 1 3 1 0
>> 3 1 4 1
>> 4 2 1 3
>> t=: 13 :'(r s y)*3 4$100*i.4'
>> 5 t 5
>> 1003 1000.69 1000.5 1001.49
>> 1001 1000.55 1000 1001
>> 1000.89 1001.03 1002 1000
>> 5 t 5
>> 1001 1002 1000 1001.37
>> 1003 1000.04 1000.23 1002
>> 1000.01 1001 1000.3 1001.16
>>
>> Be sure to get unique results as you go. Notice how to build a complex
>> result with several shorter functions.
>>
>> Linda
>>
>> ----------------------------------------------------------------------
>> For information about
>> ----------------------------------------------------------------------
>> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm