[Jprogramming] Three Simple Questions
Henry Rich
henryhrich at gmail.com
Sat Dec 2 02:35:11 UTC 2017
1.
datatype 'abc'
literal
3!:0 'abc'
2
Strings can also include 2- and 4-byte types, for which 3!:0 returns
131072 and 262144; so a complete test for string would be
(2 131072 262144 e.~ 3!:0)
2. Correct. You can return an empty value.
3. You don't need
num =. > num
etc.
Multiple assignment removes one level of boxing. See
http://code.jsoftware.com/wiki/Vocabulary/Assignment#Multiple_Assignment
Henry Rich
On 12/1/2017 8:04 PM, Dabrowski, Andrew John wrote:
> 1. How does one test whether an object is string?
>
> 2. I now know that J doesn't support nullary functions. It also seems
> that J doesn't allow functions that don't return any value (i.e. for the
> side effects), correct?
>
> 3. Suppose I want to define a dyadic function in which the y variable
> contains three values: a number, a vector, and a string. One way to do
> this would be to have y be a list of three boxes, say y = 13 ; 2 3 4 ;
> 'abcd' and parse y by
>
> fun =: dyad define
> 'num vec str' =. y
> num =. > num
> vec =. > vec
> str =. > str
> ...
> )
>
> Is this the idiomatic way to do it? Is there a better way?
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
---
This email has been checked for viruses by AVG.
http://www.avg.com
More information about the Programming
mailing list