I've wished for something like that (I'd probably classify my wish as "functional reactive programming") for APL (and more recently, for J) for a couple decades now.
That said, the idea is can introduce all sorts of problems. For example, think about what happens if you ask for the sum or shape of an array where there is no reason has been determined, yet, for an upper bound on size to exist. Thanks, -- Raul On Wed, May 28, 2014 at 10:50 PM, Devon McCormick <[email protected]>wrote: > Personally, I notice the similarity of expressiveness between the two > languages and envy Haskell's ideas of lazy evaluation and infinite lists. > > > On Wed, May 28, 2014 at 8:17 PM, Raul Miller <[email protected]> > wrote: > > > I'm not sure if it's legit to compare languages. > > > > That said, it's kind of interesting to think of how you might implement > > something like Haskell (or a subset) in J. Similarly, it's kind of > > interesting to think about how you might implement J (or a subset) in > > Haskell. (For example, you could use a tuple of maybes to represent J's > > concept of "array type", with each maybe holding the data for one > possible > > type - shape, and the type tag itself would be stored separately.) > > > > Thanks, > > > > -- > > Raul > > > > > > On Wed, May 28, 2014 at 7:50 PM, 'elton wang' via Programming < > > [email protected]> wrote: > > > > > For language comparision rather than library comparision, we need to > > > compare the "digits' source code with the J implementations here: > > > > > > > > > > > > http://hackage.haskell.org/package/digits-0.1/docs/src/Data-Digits.html#digits > > > > > > > > > -- | Returns the digits of a positive integer as a list, in reverse > > order. > > > -- This is slightly more efficient than in forward order. digitsRev > :: > > > Integral n => n -- ^ The base to use. -> n -- ^ The number to convert > > to > > > digit form. -> [n] -- ^ The digits of the number in list form, in > > reverse. > > > digitsRev base i = case i of 0 -> [] _ -> lastDigit : digitsRev base > > rest > > > where (rest, lastDigit) = quotRem i base -- | Returns the digits of a > > > positive integer as a list. digits :: Integral n => n -- ^ The base to > > use > > > (typically 10). -> n -- ^ The number to convert to digit form. -> [n] > > -- > > > ^ The digits of the number in list form. digits base = reverse . > > digitsRev > > > base > > > > > > > > > > > > On Wednesday, May 28, 2014 7:41 PM, 'elton wang' via Programming < > > > [email protected]> wrote: > > > > > > > > > > > > This may not be a good example to show Haskell's relative strength. All > > > the expressiveness comes from the handy function "digits", which is > > belong > > > to a package in Haskell, you have to "import Data.Digit" or something. > > > > > > > > > > > > > > > > > > On Wednesday, May 28, 2014 11:35 AM, Jon Hough <[email protected]> > > > wrote: > > > > > > > > > > > > Project Euler 16 is defined: > > > 215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.What is > > > the sum of the digits of the number 21000? > > > http://projecteuler.net/problem=16 > > > > > > > > > My J solution:NB. create base > > > base =. 302 $ 10 > > > > > > digitsum =. +/ @:(base & #:)"1@: (1000x &(^~)) digitsum 2 > > > As a J beginner, clearly my code is not as terse or as elegant as it > > could > > > be. But browsing the solution forums I found this Haskell solution: > > > sum $ digits 10 $ 2^1000 > > > > > > I don't know Haskell but the above code pretty much speaks for itself. > > > Clearly the solution is terse, simple and easy to understand.Comparing > > > Haskell to J, it seems one of J's strong points, terseness and rapid > > > program developing, doesn't hold up to Haskell so much as it does > against > > > C-style languages. > > > So my question is, what advantages does J hold over Haskell, in terms > of > > > speed, terseness etc? > > > Regards. > > > ---------------------------------------------------------------------- > > > 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 > > > > > > -- > Devon McCormick, CFA > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
