Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

ITT The J programming language

Name: Anonymous 2007-04-04 8:14 ID:A+7Bprzl

Examples of J: http://www.jsoftware.com/jwiki/Studio
A good introduction: http://www.jsoftware.com/help/primer/contents.htm
J for C programmers: http://www.jsoftware.com/help/jforc/contents.htm
Learning J: http://www.jsoftware.com/help/learning/contents.htm


quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)

Name: Anonymous 2007-04-04 8:19 ID:N7OPLgFv

Worse than perl.

Name: Anonymous 2007-04-04 8:25 ID:Hilt3olT

>>2
Better than APL!

J is truly the future of computation.

Name: Anonymous 2007-04-04 8:31 ID:A+7Bprzl


   [x =. 3 5 9 6 2 4 1     NB. set x to a list of numbers
3 5 9 6 2 4 1

   #x                      NB. length of x?
7

   +/ x                    NB. the / adverb is called 'insert'
30                         NB. it puts + inbetween each item of the list

   */ x
6480

   +/x % #x                NB. mean = total / count
4.28571
   (+/%#) x                NB. tactic notation (better than pointless^H^H^H^H free style)
4.28571

Name: Anonymous 2007-04-04 8:36 ID:iCSEMMSw

I've looked at some J code.  Every other character is a period or a colon.  I've got spots before my eyes.  How can anybody read this stuff?
You'll get used to it.  J has a great many primitives, and it's important to keep the names short so that you can fit a lot of computation on one line; so the names are either single characters, like >, or a character with a period or colon appended (>. and >:).  The period/colon is just part of the name.  Single letters with period/colon, like i., are also used for primitives.  If you want to assign your own names to the primitives, you are allowed to, but pretty soon you'll want to go back to the shorter names to save space and typing.

Yeah, screw readable names. It's not like people have to maintain code or anything.

Name: Anonymous 2007-04-04 8:46 ID:A+7Bprzl

>>5
"By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and in effect increases the mental power of the race." - A. N. Whitehead

"In science, each new point of view calls forth a revolution in nomenclature."  - Friedrich Engels

Name: Anonymous 2007-04-04 9:13 ID:A+7Bprzl

From http://www.cs.trinity.edu/~jhowland/math-talk/functional1/#SECTION00050000000000000000


   x =: 'x'
   y =: 'y'
   z =: 'z'
   f =: 3 : 0
'f(', y, ')'
:
'f(', x, ', ', y, ')'
)

   math_pat =: 3 : 0
'''',y,'('',y,'')''',LF,':',LF,'''',y,'('',x,'','',y,'')'''
)

f =: (3 : (math_pat 'f')) :. (3 : (math_pat 'f_inv'))
g =: (3 : (math_pat 'g')) :. (3 : (math_pat 'g_inv'))
h =: (3 : (math_pat 'h')) :. (3 : (math_pat 'h_inv'))
i =: (3 : (math_pat 'i')) :. (3 : (math_pat 'i_inv'))
j =: (3 : (math_pat 'j')) :. (3 : (math_pat 'j_inv'))


Now you can test expressions to see the function composition rules

   f x
f(x)
   f g x
f(g(x))
   (f g h) x
g(f(x),h(x))
   x (f g h) y
g(f(x,y),h(x,y))

   x f&g y
f(g(x),g(y))
   x f&g&h y
f(g(h(x)),g(h(y)))
   x f g&h y
f(x,g(h(y)))

   x f@g y
f(g(x,y))
   x (f g@h) y
f(x,g(h(y)))

Name: Anonymous 2007-04-06 12:11 ID:xIDx3a8V

cool

Name: Anonymous 2007-04-06 13:37 ID:cITkHmPU

qsort [] = []
qsort (x:xs) = qsort less ++ [x] ++ qsort more
    where (less, more) = partition (< x) xs

Name: Anonymous 2007-04-06 13:51 ID:X34ArnfV

>>9
$:@(>#[)

Name: Anonymous 2007-04-06 14:17 ID:cITkHmPU

>>10
X(

Name: Anonymous 2007-04-06 18:19 ID:UV18LUaO

qsort = lambda x: x and qsort([i for i in x[1:] if i < x[0]]) + [x[0]] + qsort([i for i in x[1:] if i > x[0]]) or []

Name: Anonymous 2007-04-06 19:40 ID:cITkHmPU

>>12
I no longer wonder why van Rossum wanted to get rid of lambdas in Python.

Name: Anonymous 2007-04-06 19:44 ID:UV18LUaO

>>13
I admit it sucked but I wanted to do it in less lines than >>9 to see if I can troll the Haskell guy one more time.

Name: Anonymous 2007-04-06 19:49 ID:e/+Ee95N

Are these quicksorts in-place? Or is this just your way to say "I've read SICP"?

Name: Anonymous 2007-04-06 20:00 ID:cITkHmPU

>>14
You succeeded.

>>15
No, they are in-SICP. But they are still the best way to demonstrate the idea of quicksort.

Name: Anonymous 2007-04-07 5:42 ID:C9MJ60zi

SPOILER: >>12 contains a bug

Name: Anonymous 2007-04-07 6:49 ID:gQ81pvl6

>>17
It's an undocumented feature!

Name: Anonymous 2007-04-07 10:20 ID:npmD/EJg

What's this then? The bastard offspring of a love-hate-orgy triangle between Haskell, Perl and Forth?

Name: Anonymous 2007-04-07 10:40 ID:J6X4fgKZ

>>19
APL, motherfucker, have you ever heard of it?

Name: Anonymous 2007-04-07 13:51 ID:6SwJdC/n

>>19
more like the future of computing!

Name: Anonymous 2007-04-07 14:30 ID:Heaven

>>21
I started the ``future of computation'' meme !!

I also started the ``tex quotes'' meme !!

Name: Anonymous 2007-04-07 14:35 ID:6SwJdC/n

>>22
ok well lets get back on topic :)

Name: Anonymous 2007-04-07 16:21 ID:WBqctclY

This ``quote style'' is superior. However, the "space - exclamation point" thing is annoying as fuck.

Name: Anonymous 2007-04-07 16:37 ID:gQ81pvl6

This “quote style” is superior‼

Name: Anonymous 2007-04-07 22:07 ID:6SwJdC/n

HOW TO MAKE Make a hypercube from a vector of length n (where n is a power of 2):

#:&.<:@# $ ]

Name: Anonymous 2007-04-09 1:51 ID:HkCRsRmr

in J zero divided by zero = zero!!!

   0%0
0

Name: Anonymous 2007-04-09 1:54 ID:onhmdO/m

^^wrong

0=0

4%

Name: Anonymous 2007-04-09 2:00 ID:6bs2IFb4

Dividing by zero considered overrated

Prelude> 1/0
Infinity

Name: Anonymous 2007-04-09 2:47 ID:onhmdO/m

^dude that's wrong.

Prelude<^`2/5
Indafo,cic

Name: Anonymous 2007-04-09 3:09 ID:cBVQTJDh

>>29
I just lost a little piece of respect for Haskell.

Name: Anonymous 2007-04-09 3:39 ID:Heaven

Using Haskell considered retarded

Name: Anonymous 2007-04-09 5:50 ID:Y4qqp/vv

>>29
bitches don't know about my integer division

Hugs.Base> 1 `div` 0

Program error: divide by zero

Name: Anonymous 2007-04-09 5:59 ID:Heaven

data Surreal = APlainBoringNumberNoOneReallyCaresAbout Double | OhShi

(/////////) :: Num a => a -> a -> Surreal
(/////////) _ 0 = OhShi
(/////////) a b = APlainBoringNumberNoOneReallyCaresAbout $ a / b

Name: Anonymous 2007-04-09 6:49 ID:t6bi9DTl

>>31,32
Don't blame Haskell. Blame the IEEE:
http://en.wikipedia.org/wiki/IEEE_754

Name: Anonymous 2007-04-09 12:14 ID:r5Sr3yLw

itt: crap programming languages nobody uses FOR A REASON

Name: Anonymous 2007-04-09 13:11 ID:HkCRsRmr

>>36
lots of people use it because its simply the best tool for the job they are doing.

Name: Anonymous 2007-04-09 13:27 ID:lC6diV8H

The job they're doing being nothing.

Name: Anonymous 2007-04-09 15:22 ID:8lxHqepV

>>17
So what's the bug?

Name: Anonymous 2007-04-09 15:28 ID:Heaven

>>39
What happens when you sort a list which contains duplicate elements?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List