# Tutorials?

## francisnorton — 2003-05-16 08:02:44

    I've been going throught the Informal Tutorial and I have a slight

    problem with constr12 operator, which doesn't seem to be implemented

    in either the core language or the libraries. Can anyone point me to

    an implementation?

    Also, any recommendation on tutorial or sample code for good file IO

    or standard IO practice?

    Thanks -

    Francis.

## Heiko.Kuhrt@t-online.de — 2003-05-17 08:14:13

    On Friday May 16 2003 10:02, francisnorton wrote:

     > I've been going throught the Informal Tutorial and I have a slight

    > problem with constr12 operator, which doesn't seem to be implemented

    > in either the core language or the libraries. Can anyone point me to

    > an implementation?

    >

     I've never seen an implementatin of *constr12* . I think it's from

    pre-Joy1-times. Try *construct* .

     > Also, any recommendation on tutorial or sample code for good file IO

    > or standard IO practice?

     Manfreds way of intermixing code and joy shell in/output seems to be a

    sort of standard IO practice.

     >

    > Thanks -

    >

    > Francis.

## phimvt@lurac.latrobe.edu.au — 2003-05-19 11:13:22

    On Sat, 17 May 2003 Heiko.Kuhrt@... wrote:

     > On Friday May 16 2003 10:02, francisnorton wrote:

    > > I've been going throught the Informal Tutorial and I have a slight

    > > problem with constr12 operator, which doesn't seem to be implemented

    > > in either the core language or the libraries. Can anyone point me to

    > > an implementation?

    > >

    > I've never seen an implementatin of *constr12* . I think it's from

    > pre-Joy1-times. Try *construct* .

     How embarrassing. Another oversight by me. Thank you Francis and Heiko.

    The replacement is "cleave". So the example to compute the

    arithmetic mean of the numbers in an aggregate is

          [0 [+] fold]   [size]   cleave    /

    I have fixed that part in the tutorial.

     > > Also, any recommendation on tutorial or sample code for good file IO

    > > or standard IO practice?

    > Manfreds way of intermixing code and joy shell in/output seems to be a

    > sort of standard IO practice.

     I tend to do this:

       1. For more or less established libraries:

            mostly definitions triggered by LIBRA, and

            a small number of other calls of informative messages

       2. For testing new additions in libraries:

    	add the new definition in the library, but

            have a separate file of throw-away tests.

       3. For proof-of-concept non-permanent stuff

          (e.g. the new nestrec examples):

          definitions triggered by DEFINE,

          immediately followed by some tests and demos

    I also have to confess that I have not used John Cowan's

    Joy1 additions for files very much, apart from testing

    my understanding (rather than his implementation). If

    anyone on the group has even a small library of these

    additions I would be very glad to see them. One operator

    which I can think of that might be quite useful is

    "strinclude" (string include). It would take a string

    as a parameter, put that string to a temp file, and then

    "include" that file on the input file stack (for normal

    input or for gets). Should be quite easy. But there must

    be lots of useful things one can do with the new file operations.

    Thank you both.

    Also, John, I'm very impressed by Joy in Scheme. But I'll

    have to awake from my SICP timewarp and start learning

    about Scheme macros...

      - Manfred

## John Cowan — 2003-05-19 12:02:10

    phimvt@... scripsit:

     > Also, John, I'm very impressed by Joy in Scheme.

     I'm hoping to get it wrapped up in a week or two.

     > But I'll

    > have to awake from my SICP timewarp and start learning

    > about Scheme macros...

     I had a little help there from the good folks on comp.lang.scheme,

    specifically with the recursive joy-let macro.  All the other

    macros should be easy to understand: the body of syntax-rules is

    simply a bunch of cases and their expansions.  The nice thing about

    R5RS macros is that they are guaranteed hygienic: the identifiers

    used in the cases are alpha-converted so that they cannot collide

    with identifiers used in the calls.

    --

    John Cowan       http://www.ccil.org/~cowan        <jcowan@...>

            You tollerday donsk?  N.  You tolkatiff scowegian?  Nn.

            You spigotty anglease?  Nnn.  You phonio saxo?  Nnnn.

                    Clear all so!  `Tis a Jute.... (Finnegans Wake 16.5)

## Nick Forde — 2003-05-19 13:14:15

    phimvt@... writes:

      > I also have to confess that I have not used John Cowan's

     > Joy1 additions for files very much, apart from testing

     > my understanding (rather than his implementation). If

     > anyone on the group has even a small library of these

     > additions I would be very glad to see them. One operator

     > which I can think of that might be quite useful is

     > "strinclude" (string include). It would take a string

     > as a parameter, put that string to a temp file, and then

     > "include" that file on the input file stack (for normal

     > input or for gets). Should be quite easy. But there must

     > be lots of useful things one can do with the new file operations.

     As Joy contains most (all?) I/O functions found in ANSI C I believe a

    powerful I/O library could be quite easily written. To seriously use a

    programming language on a daily basis for me good string and IO

    support is essential. I think this is one reason why Ruby, Python and

    Perl are so popular.

    Although the Joy support for I/O is farily basic it is still useful

    for writing text manipulation utilities. Most of those I've written

    have been something like the following which will filter either stdin

    or a user supplied file line by line.

    -----------------------------------------------------------------------------

    #!/usr/local/bin/joy

    # head - write the first part of a file to stdout

    # synopsis: head [NUMLINES [FILE]]

    # $Id: head.joy,v 1.1 2003/05/17 13:31:06 nickf Exp nickf $

    DEFINE usage   == "usage: head [NUMLINES [FILE]]\n" putchars.

    DEFINE getopts == [argc 2 >] [argv third "r" fopen ] [stdin] ifte

                      [argc 1 >] [argv second 10 strtol] [15   ] ifte

                      [argc 3 >] [usage quit           ] [     ] ifte.

    DEFINE rhead   == getopts [0 =] [pop2] [1 - [fgets putchars] dip] tailrec.

    DEFINE ihead   == getopts [fgets putchars] times pop.

    ihead.

    -----------------------------------------------------------------------------

    Replacing "putchars" in the ihead definition and removing the line

    counter it is quite easy to write Unix like utilities for text

    processing.

    Francis, I'm not sure if this is the kind of thing you were looking

    for but hopefully the above will be of some use.

    Regards,

    Nick.

## John Cowan — 2003-05-19 13:47:46

    Nick Forde scripsit:

     > As Joy contains most (all?) I/O functions found in ANSI C

     All, by intention.

    --

    Evolutionary psychology is the theory           John Cowan

    that men are nothing but horn-dogs,             http://www.ccil.org/~cowan

    and that women only want them for their money.  http://www.reutershealth.com

            --Susan McCarthy (adapted)              jcowan@...

## Francis Norton — 2003-05-19 15:11:04

    Nick Forde wrote:

     >Francis, I'm not sure if this is the kind of thing you were looking

    >for but hopefully the above will be of some use.

    >

     Thank you Nick, this is exactly the kind of thing I was looking for - a

    really useful start point.

    --

    "Never mind manoeuvre, go straight at 'em." - Admiral Horatio Nelson