Hello John,

just interpreting what you mean (but I may misunderstand it completely). With a list comprehension you can formulate:
(just a simple example)

Prelude> take 6 $ [ (^2) x | x <- [0..], 0 == x `mod` 2]
[0,4,16,36,64,100]

In J:

   (*:#~0=2&|) i.12
0 4 16 36 64 100

Perhaps something like this?


Jon Hough schreef op 27-12-14 om 15:26:
Hi Aai,

I see what you are saying, but I would say that implicitly inside f there is some sort of 
"such that" syntax.
My motivation for asking for a "such that / where" construct is to create 
computable math definitions, as in Haskell.

for example, if I want the set (or group):

{ x e. Sym(4) | order(x) = 4} (where Sym(4) is the symmetric group on 4 letters)

then, assuming I have a verb "sym" and a verb "order" I can do


(sym 4) where (4&=@:order)
Then it may just be possible to generate groups from group presentations ( 
http://en.wikipedia.org/wiki/Presentation_of_a_group)(I haven't figured out how 
to do this, I am just thinking about it over the holidays)

Date: Sat, 27 Dec 2014 08:46:12 +0100
From: agroeneveld...@gmail.com
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] "Such that" syntax in J

Sorry for jumping in late.

The Haskell expression you showed here is called a list comprehansion
which can be easily formulated as

map f xs

and this is in J simply:

f xs







Jon Hough schreef op 26-12-14 om 17:04:
In Haskell (and other languages I'm sure) one can express the idea of "such 
that" to denote one expression depending on another. In Haskell we can use the 
syntax:

[ f x | x <- xs ]

which means
   "the list of all f x
such that x is drawn from xs."

So | is syntactically similar to the English "such that". (and very much like | 
in mathematical sets)

I would like to know if J has a construct to express the above Haskell code.

Thanks,
Jon.
                                        
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
Met vriendelijke groet,
@@i = Arie Groeneveld

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

--
Met vriendelijke groet,
@@i = Arie Groeneveld

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

Reply via email to