perhaps ‘where’ ? where=: 2 : '(#~ v) m’ (2+i.20) where (1&p:) 2 3 5 7 11 13 17 19
which you could read as … prime=:1&p: (2+i.20) where prime This is close to the kdb+ <where> statement, although in a different contextual syntax. Regards Rob > On 27 Dec 2014, at 10:35 am, Raul Miller <[email protected]> wrote: > > Well.. "such that" sort of implies that u appears on the right and the > value for x on the left. You can do that in J, but you'll need extra > parenthesis, quite often: > > such_that=: 2 : '(#~ v) m' > (2+i.20) such_that (1&p:) > 2 3 5 7 11 13 17 19 > > So it seems to me that another name should be used for 1 :'(#~ u) y' > -- perhaps 'selected_from' or something like that? > > Still, technically speaking, you are correct, if we ignore the fuzzy > aspects of human language. > > Thanks, > > -- > Raul > > On Fri, Dec 26, 2014 at 11:38 AM, Jon Hough <[email protected]> wrote: >> #~g seems to work. (Much neater than my code) >> e.g. for my prime set >> >> >> >> g =: 1&p: >> >> (#~g) i. 100 >> gives what I want. >> >> So I suppose an adverb of the form #~u for verb u is close to "such that"? >> >>> From: [email protected] >>> Date: Fri, 26 Dec 2014 11:25:13 -0500 >>> To: [email protected] >>> Subject: Re: [Jprogramming] "Such that" syntax in J >>> >>> Now it sounds like you want: >>> (#~ g) x >>> >>> Assuming, of course, that x and g are appropriate. >>> >>> I hope this helps, >>> >>> -- >>> Raul >>> >>> >>> On Fri, Dec 26, 2014 at 11:20 AM, Jon Hough <[email protected]> wrote: >>>> Thanks for replying. >>>> >>>> I'm confused about two things. >>>> >>>> (1) I'm worried I haven't explained myself well. >>>> I mean I want to find all x given g(x) is true for some function g. >>>> >>>> i.e. the set { x | g(x) is true } >>>> (You may have answered this, I need to read your example more carefully, >>>> but this leads me to problem 2...) >>>> >>>> (2) I don't understand what >>>> ←→ >>>> means in terms of J. These are not ASCII characters or J primitives. >>>> >>>> Thanks. >>>> >>>>> Date: Fri, 26 Dec 2014 08:13:40 -0800 >>>>> From: [email protected] >>>>> To: [email protected] >>>>> Subject: Re: [Jprogramming] "Such that" syntax in J >>>>> >>>>> f x >>>>> >>>>> where x is an array of all values of interest. For (countably) infinite >>>>> sets you have to express x in terms of i._ . For example, to express the >>>>> Euler product formula for the Riemann zeta function, >>>>> >>>>> +/(1+i._)^-s ←→ */%1-(p:i._)^-s >>>>> >>>>> >>>>> >>>>> On Fri, Dec 26, 2014 at 8:04 AM, Jon Hough <[email protected]> wrote: >>>>>> >>>>>> 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 >>>>>> >>>>> ---------------------------------------------------------------------- >>>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>> >>>> ---------------------------------------------------------------------- >>>> For information about J forums see http://www.jsoftware.com/forums.htm >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >> >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
