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

Pages: 1-

Man or Boy Test

Name: Anonymous 2013-03-22 11:34

http://en.wikipedia.org/wiki/Man_or_boy_test

Symta:

a K X1 X2 X3 X4 X5 = b:(= a !K-1 @b X1 X2 X3 X4)
                   = <K le 0 = X4{} + X5{} | b>
man_or_boy X = a X (=1) (=~1) (=~1) (=1) (=0)
man_or_boy 10


Lisp:

(define (A k x1 x2 x3 x4 x5)
  (define (B)
    (set! k (- k 1))
    (A k B x1 x2 x3 x4))
  (if (<= k 0)
      (+ (x4) (x5))
      (B)))
 
(define (K x) (lambda () x))
(A 10 (K 1) (K -1) (K -1) (K 1) (K 0))


Haskell:

import Control.Monad
import Data.IORef
 
a k x1 x2 x3 x4 x5 = do r <- newIORef k
                        let b = do k <- pred !r
                                   a k b x1 x2 x3 x4
                        if k <= 0 then liftM2 (+) x4 x5 else b
    where f !r = modifyIORef r f >> readIORef r
 
main = a 10 #1 #(-1) #(-1) #1 #0 >>= print
    where (#) f = f . return



C/C++:

#include <iostream>
#include <tr1/memory>
using std::tr1::shared_ptr;
using std::tr1::enable_shared_from_this;
 
struct Arg {
  virtual int run() = 0;
  virtual ~Arg() { };
};
 
int A(int, shared_ptr<Arg>, shared_ptr<Arg>, shared_ptr<Arg>,
      shared_ptr<Arg>, shared_ptr<Arg>);
 
class B : public Arg, public enable_shared_from_this<B> {
private:
  int k;
  const shared_ptr<Arg> x1, x2, x3, x4;
 
public:
  B(int _k, shared_ptr<Arg> _x1, shared_ptr<Arg> _x2, shared_ptr<Arg> _x3,
    shared_ptr<Arg> _x4)
    : k(_k), x1(_x1), x2(_x2), x3(_x3), x4(_x4) { }
  int run() {
    return A(--k, shared_from_this(), x1, x2, x3, x4);
  }
};
 
class Const : public Arg {
private:
  const int x;
public:
  Const(int _x) : x(_x) { }
  int run () { return x; }
};
 
int A(int k, shared_ptr<Arg> x1, shared_ptr<Arg> x2, shared_ptr<Arg> x3,
      shared_ptr<Arg> x4, shared_ptr<Arg> x5) {
  if (k <= 0)
    return x4->run() + x5->run();
  else {
    shared_ptr<Arg> b(new B(k, x1, x2, x3, x4));
    return b->run();
  }
}
 
int main() {
  std::cout << A(10, shared_ptr<Arg>(new Const(1)),
                 shared_ptr<Arg>(new Const(-1)),
                 shared_ptr<Arg>(new Const(-1)),
                 shared_ptr<Arg>(new Const(1)),
                 shared_ptr<Arg>(new Const(0))) << std::endl;
  return 0;
}

Name: Anonymous 2013-03-22 11:36

I am beyond offended at this, on behalf of all females.

Name: Anonymous 2013-03-22 11:39

"Woman or Girl Test" sounds insultingly sexist.

Name: Anonymous 2013-03-22 11:40

C
class B : public Arg, public enable_shared_from_this<B>


Do I need to reread the standard?

Name: Anonymous 2013-03-22 12:04

BTW, Man or Boy test shows that JavaScript is a lot better than Lua:
http://lua-users.org/lists/lua-l/2008-11/msg00008.html

Name: Anonymous 2013-03-22 12:06

>>5
The statement "function B() ... end" is writing to the global variable B each time. Try "local function B() ... end" instead.
Yeah, thanks! That was the only problem. Now everything works as
expected.

NEXT!

Name: Anonymous 2013-03-22 12:18

>>6
user is the problem.

Shalom, Hymie! Blaming the victim is typical Jewish tactics.

Name: Anonymous 2013-03-22 12:37

>>7
PEBGAS
Problem exists between goy and shower.

Name: Anonymous 2013-03-22 15:20

Problem exists between planet and kike parasite.

Name: Anonymous 2013-03-22 15:22

Nikita, Nikita, Nikita, NIKITA.

IF YOU POST A FUCKING SNIPPET WITH OOP SHIT AND TEMPLATES, IT'S C++, NOT C/C++. FUCK YOU FAGGOT.

Name: Anonymous 2013-03-22 15:37

>>1
I puked a little at every one except Lisp.

Name: Anonymous 2013-03-22 17:41

>>10
implying C is better than C++

Name: Anonymous 2013-03-22 17:44

>>11
Aw, poor little jew can't handle the superiority of Symta. Just like he can't handle the superiority of the white races over the parasitic jews.

Name: Anonymous 2013-03-22 17:46

>>13
if goyim are so superior, then why are they the jews' bitches nowadays? CHECKMATE, DELICATE FLOWER

Name: Anonymous 2013-03-22 18:24

>>13
Superiority needs documentation.
Where is it, nikita??!?!?
I'm losing money every day and my client is mad
I might have to use FIOC to cut the lost development times.

Name: Anonymous 2013-03-22 18:26

someone should port symta to javascript, nikita would go fucking apeshit

Name: Anonymous 2013-03-22 18:30

Name: Anonymous 2013-03-22 18:31

>>16
Nikita is already a macfag, I doubt he cares.

Name: Anonymous 2013-03-22 18:32

I might have to use FIOC to cut the lost development times.
Soon you will have two problems.

Name: Anonymous 2013-03-22 18:33

>>15
He isn't me. He is just some Jew, trying to make me look arrogant.

Name: Anonymous 2013-03-22 18:39

>>16
holy fuck, just imagine the fit he would throw after someone rewrites an al-arabiyyah language in a kike language

Name: Anonymous 2013-03-23 6:01

>>1 I believe you mean:

Symta/Fortran/COBOL:

a K X1 X2 X3 X4 X5 = b:(= a !K-1 @b X1 X2 X3 X4)
                   = <K le 0 = X4{} + X5{} | b>
man_or_boy X = a X (=1) (=~1) (=~1) (=1) (=0)
man_or_boy 10

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