From cs2322 at ariel.cs.trinity.edu  Wed Sep 13 17:37:20 2006
From: cs2322 at ariel.cs.trinity.edu (John Howland)
Date: Wed Sep 13 17:38:11 2006
Subject: [CSCI2322] Re: Class Examples
In-Reply-To: <1D6B1A9F3184E14FA5EA7D766E538A5242140E@its-hardin.trinity.local>
References: <1D6B1A9F3184E14FA5EA7D766E538A5242140E@its-hardin.trinity.local>
Message-ID: <Pine.OSX.4.58.0609131623050.2644@leda.cs.trinity.edu>

On Wed, 13 Sep 2006, Alcantar, Ricardo wrote:

> Dr. Howland,
>
> Is there any way for us to see the examples that we do in class?

Ricardo,

Good question.  I have answered this verbally, but here are the
nitty gritty details (I'm copying this reply to our class mailing list
so all can see).

If you copy /users/jhowland/.jhistory to some file in your home directory , i.e.,

cp /users/jhowland/.jhistory ./howland-jhistory

and then call that file up in an editor (such as vi) to select,
by deleting the lines before and after what were used for a
given lecture, say the lecture of 20060912 (I found I had to
delete the last 13 lines because I used J in my graphics class
after functional programming on 20060912), I had the following
file named

howland-jhistory :


verb
dyad
foo =: verb define
- y.
:
x. - y.
)
3*foo 4
3*4foo 5
3*4 foo 5
names
4!:1 ''
a =: i. 10
4!:1 ''
noun
4!:1 0
(4!:1) 0
(4!:1) 3
1 2 3 , 4 5
1 2 3 ,'abc'
< 1 2 3
(<1 2 3) , <'abc'
b =:(<1 2 3) , <'abc'
1 { b
2 0 from b
1 0 from b
b
0 { b
> 0 { b
1 { > 0 { b
b
<b
link
 1 2 3 ; 'abc'
i. 10
;/i.10
;/'abcdef'
bar =: 222222222222222222222222222222222222222x * 555555555555555555555555555555555555555555555555x
bar
foo
bar1 =: bar ; 1 2 3 ; 'now is the time'
bar1
bar
names noun
names verb
names
(4!:1) noun
> (4!:1) noun
$ > (4!:1) noun
' ' = 0{ > (4!:1) noun
 0{ > (4!:1) noun
$ 0{ > (4!:1) noun
names noun
('de';'foo1') =: 3 4
name noun
names noun
de
foo1
names noun
#names noun
'n1 n2 n3 n4 n5 n6
'n1 n2 n3 n4 n5 n6' =: names noun
n1
n3
'x y z' =: 1 2
'x y z' =: 1
x
y
z
names verb
names noun
foo2 =: monad define
'a b c' =. y.
%a*b-c
)
a
foo2 3 4 5
a
b
c
foo2 =: monad define
'a b c' =. x: y.
%a*b-c
)
foo2 3 4 5
%3x
x: .333333
x: .33333333333333333333333333333333
x: .333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
ls =: 10000$ 0.01
+/ls
print_precision
print_precision''
set_print_precision 17
print_precision''
+/ls

These are the expressions which I typed into J during the 20060912 lecture.
I had to delete a lot of lines at the beginning of the file because this history
is quite large.  It is probably best to work backwards when deleting lines.
Before exiting the editing session, add a last line of

exit 0

All of this work should be done in your cs2322j directory.

To re-create both input an output for the session, enter the following
unix command:

echo "lecture'howland-jhistory'" | j > 20060912-lecture

This tells J to run the J program called lecture on the file

howland-jhistory

and send the output to

20060912-lecture

You then have a copy of the complete lecture session.  Isn't J neat!

I have done this for the 20060912 lecture and left the above named files
in ~jhowland/cs2322j .

John


>
> thanks,
>
> _____________________
> Ricardo Alcantar
> Trinity University
> One Trinity Place #1005
> San Antonio, TX. 78212
> (210)843-8033
> Ricardo.Alcantar@trinity.edu
>

_______________________________________________________________
John E. Howland       url: http://www.cs.trinity.edu/~jhowland/
Computer Science    email: jhowland@ariel.cs.trinity.edu
Trinity University  voice: (210) 999-7364
One Trinity Place     fax: (210) 999-7477
San Antonio, Texas  78212-7200
From jhowland at ariel.cs.trinity.edu  Wed Sep 20 10:30:43 2006
From: jhowland at ariel.cs.trinity.edu (John Howland)
Date: Wed Sep 20 10:30:45 2006
Subject: [CSCI2322] Re: homework 3 help
In-Reply-To: <8879A68B52FC4045AF1AC45D3A94482E2C191D@its-hardin.trinity.local>
References: <8879A68B52FC4045AF1AC45D3A94482E2C191D@its-hardin.trinity.local>
Message-ID: <Pine.OSX.4.58.0609201014050.2373@leda.cs.trinity.edu>

On Tue, 19 Sep 2006, Horn, Britton wrote:

>
> Dr. Howland,
>
> I was having some trouble with homework 3. I can't figure out how to make it into a dyad. I tried using append and compose but those don't work (at least not where I used them). If there is a place where I could go on the internet to find help that would be great. This is the most I've gotten for a function, but I get a length error if I use it:

Britton,

The question seems (to me) to be "What should the arguments be of the new_compress function?"

The answer I would give is that the right argument should be the same
as that of compress and the left argument should be a list of items
(notice I didn't say characters -- think in more general terms) which,
if next to each other, should be treated as adjacent separators which
are to be compressed to a single separator.  For example:

' ' new_compress 'hi   there' ==> 'hi there' just as compress does, but
(' ',9{a.) new_compress text  should treat both space and tab as separator items and:

1 2 new_compress 3 1 1 4 5 1 2 9 10 ==> 3 1 4 5 1 9 10
1 2 new_compress 3 1 1 4 5 2 1 9 10 ==> 3 1 4 5 2 9 10

Your question is good, so I'm copying our class discussion list
also.

John

>

[lines deleted]

>
> Any help would be greatly appreciated,
>
> Britton Horn
>

_______________________________________________________________
John E. Howland       url: http://www.cs.trinity.edu/~jhowland/
Computer Science    email: jhowland@ariel.cs.trinity.edu
Trinity University  voice: (210) 999-7364
One Trinity Place     fax: (210) 999-7477
San Antonio, Texas  78212-7200
