On Nov 26, 2007 2:32 AM, neville holmes <[EMAIL PROTECTED]> wrote:
> If a student writes something incomprehensible like:
> sample=3D: (({. + {: * i.@(>.@((1&{ - {.) % {:))) , 1&{)@(3&{.@(({.~ (#
> +
> _3&*@(1: =3D #))) , %&100@(-~/@(_2&{.)))) :([EMAIL PROTECTED] ([EMAIL 
> PROTECTED] + ((1&[EMAIL PROTECTED] -
> [EMAIL PROTECTED]) %
> [) * i.@(1: + [)) (>@(2&>@#) |. 2&{.)@])
> which is just Iverson's "steps" with several defaults built in, how can
> I get him to record these options and the syntax for the function.

First, if I were teaching  J, I would impose a line length limit on
acceptable results.  I would reject anything longer than 25
J words, maybe (or some other arbitrarily chosen limit -- perhaps
chosen for the entire class or perhaps chosen for each assignment),
and ask them to rewrite any such thing (or mark it as a failure if
they fail to do so).  I might also impose a minimum line length
restriction where only one word's definition may be less than this
minimum length.  (Ten J words, maybe.)

To motivate these constraints, I might spend a few minutes
talking about poetry and its construction.  (Note also that the
above constraints are mere possibilities.)

Since sample could have been rewritten:

samples=: {. + (1&{ - {.) * (i.@>: % ])@[EMAIL PROTECTED]:
sdefault=: (1 0 2{ ], 0 0 0.01}.~ #) : ((] ,~ 0 0 0.01 (}.~-) #)@(] , [EMAIL 
PROTECTED]))
sample=: [EMAIL PROTECTED]

Note ''
    sdefault   7     is 0 7 0.01
    sdefault 3 7     is 3 7 0.01
    sdefault 3 7 0.5 is 3 7 0.5
  2 sdefault   7     is 0 7 0.5
  2 sdefault 3 7     is 3 7 0.5
)

I would be strongly tempted to introduce constraints and intermediate
step problems for that assignment (if I repeated it) which would guide
the student towards this style of solution.

I would even more strongly be tempted to guide students towards a
style of defaults which can be more easily documented.

Second, while I agree that retaining comments in tacit definitions
could be nice, from a code reading point of view, I should also
point out that well chosen names can serve an analogous role.

Note also that your above example got mutilated by email.  I see =3D
which looks like = as modified by quoted-printable encoding which
was then not properly decoded.  Here's a slightly cleaned up version:

sam=: ''1 :(0 :0-.LF)
  (({. + {: * i.@(>.@((1&{ - {.) % {:))) ,
   1&{)@(3&{.@(({.~ (# + _3&*@(1: = #))) ,
    %&100@(-~/@(_2&{.))))

  :([EMAIL PROTECTED] ([EMAIL PROTECTED] + ((1&[EMAIL PROTECTED] - [EMAIL 
PROTECTED]) % [) *
   i.@(1: + [)) (>@(2&>@#) |. 2&{.)@])
)


For this example, I think that those defaults should go
in with a different name (or names) than the computational
function, as I illustrated above.

> If (steps 2 3 4),(4 sample 2 3),: (sample 2 3 0.25)
> all produce the same result how is a user to find out?  In fact,
> finding what "steps" does and its correct syntax (it loads with
> the Plot functions) is a challenge in itself without introducing
> user defined functions.

When I type in the word "steps", then hit control-F1 I get a popup window
which gives its syntax.    Unfortunately, this window does not scroll
to the correct point, and does not have a search function, so I have to
manually scan everything in it (and 'steps' is at the bottom).

> There's a lot I don't like about Matlab but I do like it's "help"
> function.  Can it be true that no one has written something to work in
> J in a similar fashion?

I believe that J's control-F1 functionality can be made to work for user
defined code, but I have not studied its mechanisms and can not say
how easy or obnoxious this would be (with or without some helper utility).

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to