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

Pages: 1-

u wut m8

Name: Anonymous 2012-09-22 12:08


$ racket
Welcome to Racket v5.1.3.3
(+)
0

Name: Anonymous 2012-09-22 12:28

Name: Anonymous 2012-09-22 13:00

(/ (*) (- (*) (*)))

Name: Anonymous 2012-09-22 14:08


(define (a-plus-abs-b a b)
  ((if (> b 0) + -) a b))

Name: Anonymous 2012-09-22 14:46

>>4
Haskell is superior:
a-plus-abs-b = (+ abs)




















instance (Num a, Eq a) => Num (x -> a) where
    fromInteger = const . fromInteger
    f + g = liftM2 (+) f g
    f * g = liftM2 (*) f g
    f - g = liftM2 (-) f g
    negate = (negate .)
    abs = (abs .)
    signum = (signum .)

Name: Anonymous 2012-09-22 14:47

>>5
s/-/_/g

Name: Anonymous 2012-09-23 4:23

Fun fact: in the J programming language, (f g) = x f (g y) if f is a binary operator and g is a unary one.

   f =. +|
   _10 f _20

Name: Anonymous 2012-09-23 14:58

>>7
http://wiki.nars2000.org/index.php/Trains
It's the same way in NARS2000 Extended APL (which adopted them from J).
      f←(+|)
      ¯10 f ¯20

It can also be written with the operator.
      f←+∘|
      ¯10 f ¯20

Name: Anonymous 2012-09-23 15:05

>>1,2
APL arithmetic functions also return the identity element when given an empty vector.
      +/⍳0
0
      -/⍳0
0
      ×/⍳0
1
      ÷/⍳0
1
      */⍳0
1

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