Dan, I can see the reasoning behind the fact that the two results are like 
comparing apples and oranges, but to answer the universal "true" is jarring, 
don't you think?

Linda

-----Original Message-----
From: Programming [mailto:[email protected]] On Behalf 
Of Dan Bron
Sent: Tuesday, January 26, 2016 12:53 PM
To: J Programming
Subject: Re: [Jprogramming] Monday Morning Wake Up Exercise

Linda wrote:
> I thought a 1 result meant the two images are the same.  The first comparison 
> I thougth confirmed that the two images that look alike to me really are the 
> same. The colors seem ok but I wasn't sure.


In J, all verbs (as well as adverbs and conjunctions) produce a result, an 
output, every time they’re invoked with arguments. This is a fundamental 
feature of J’s grammar. There is no way to invoke a verb (or adverb, or 
conjunction) and not produce an output.

Though J leans towards functional programming, it is not a pure functional 
programming language in the sense (e.g.) Haskell is.

Which is to say, verbs are sometimes employed solely for their side-effects [1] 
—  like viewmat is for its side effect of creating and displaying a new GUI 
window — and in these cases we don’t care about the verb’s output. But the verb 
is still obliged to produce one. It can’t not.

In these cases, the convention in J is for such side-effect-focused verbs to 
return i.0 0, because the display of i.0 0 in J is zero lines (each containing 
zero characters), which of course means nothing is displayed at all.  That way, 
there’s no distracting and irrelevant (because the results of 
side-effect-focused verbs are irrelevant) text clogging up the session log.  

So no, -: does not compare the pictures viewmat paints (that’s a side-effect -: 
has no access to), it compares the results, the output, of the verb viewmat, 
which is always i.0 0, irrespective of input. Therefore (viewmat SOMETHING) -: 
(viewmat SOMETHING_ELSE) is always true (leaving aside errors and exceptions 
and non-J-IDE platforms, etc).

In other words, no (viewmat SOMETHING) -: (viewmat SOMETHING_ELSE) does NOT 
tell you whether SOMETHING and SOMETHING_ELSE “look the same”.

-Dan

[1] A side-effect being some environmental (state) change unrelated to the 
actual output or result of the verb proper. If you think of a verb (or 
generally a function) as a pipe where you shove inputs in one end and collect 
outputs at the other end, then the side-effects are all the stuff that leaks 
out the side of the pipe before it gets to the output end.  

Here, the side-effect in question is viewmat changing the color of some of the 
pixels on your monitor, as opposed to its output proper, which is always i.0 0, 
regardless of which pixels it changed and how.


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

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

Reply via email to