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

Man or boy test.

Name: Anonymous 2014-05-25 5:37

http://rosettacode.org/wiki/Man_or_boy_test

So, how does your weapon of choice fare?

Name: Anonymous 2014-05-26 17:09

>>35
My Scheme interpreter passes the test with
(lambda () 1) (lambda () -1) (lambda () -1) (lambda () 1) (lambda () 0)))
with being shit.

Name: Anonymous 2014-05-26 20:35

>>41

(define m (lambda (x) (lambda () x)))

(A 10 (m 1) (m -1) (m -1) (m 1) (m 0))

Name: Anonymous 2014-05-26 20:48

>>37
Oh, nice. Does memory usage remain more or less constant?

>>39
It's not meaningful without lambdas for example. Some langauge implementations have problems with memory. I don't think you're supposed to need 4gb to compute k = 26, but GHC does.

Name: Anonymous 2014-05-26 21:04

>>42
D:
A(10, 1, -1, -1, 1, 0)

Scheme:
(define m (lambda (x) (lambda () x)))
(A 10 (m 1) (m -1) (m -1) (m 1) (m 0))

Name: Anonymous 2014-05-26 21:14

>>44
And now someone's going to macro it up (in CL) and it'll be a short and incomprehensible mess. Then someone else will come along and do it in J. Will you be happy then?

Name: Anonymous 2014-05-26 21:21

>>44
The D versions look suspect. The first one is plain wrong. Not sure about the others, can you really invoke an int in D as though it's a nullary function returning int? (Weird feature. Even Perl isn't that DWIMMy.)

Name: Anonymous 2014-05-26 21:26

>>44
Shit I spent like 5 minutes staring at this post trying to figure out what you were making a frowny face at, until I read >>46 and realized that was the implementation in ``D''.

Niggers.

Name: Anonymous 2014-05-26 21:51

>>43
Huh. Using massif in valgrind I just found out my implementation uses less memory than guile and also frees it in the most efficient way.

Valgrind --tool=massif heap allocation graph for guile:

MB
3.508^ #
| #
| #
| #
| #
| :@ :::::::#
| @:@:: :@::#
| @:@:: :@::#
| 2.1MB ------- My interpreter's peak '@:@:: :@::#
| :@:@::::@::@:@:: :@::#
| ::::@:::@:@:@:: @::@:@:: :@::#
| ::: @:::@:@:@:: @::@:@:: :@::#
| :::::::::::: @:::@:@:@:: @::@:@:: :@::#
| ::: :::::::: @:::@:@:@:: @::@:@:: :@::#
| :::::::::::::::::::::: :::::::: @:::@:@:@:: @::@:@:: :@::#
| ::: :: : : ::: ::::: :::::::: @:::@:@:@:: @::@:@:: :@::#
| :::@:::::: :: : : ::: ::::: :::::::: @:::@:@:@:: @::@:@:: :@::#
| :::::@:::::: :: : : ::: ::::: :::::::: @:::@:@:@:: @::@:@:: :@::#
| :::::::@:::::: :: : : ::: ::::: :::::::: @:::@:@:@:: @::@:@:: :@::#
| :::::::@:::::: :: : : ::: ::::: :::::::: @:::@:@:@:: @::@:@:: :@::#
0 +----------------------------------------------------------------------->Mi
0 118.5
Number of snapshots: 93
Detailed snapshots: [9, 40, 44, 46, 48, 53, 63, 70, 80, 90, 92 (peak)]


Heap allocation graph for my interpreter:


MB
2.025^ ##
| @# :
| @:@# @@:::::
| ::@:@# @ : : ::::::::::
| ::@:@# @ : : ::::: :: :::::::
| ::::@:@# @ : : ::::: :: ::: :: :::::::::
| @@: ::@:@# @ : : ::::: :: ::: :: :: ::: : :::
| @ : ::@:@# @ : : ::::: :: ::: :: :: ::: : :::@::::
| ::@ : ::@:@# @ : : ::::: :: ::: :: :: ::: : :::@::: : :
| : @ : ::@:@# @ : : ::::: :: ::: :: :: ::: : :::@::: ::::::
| ::: @ : ::@:@# @ : : ::::: :: ::: :: :: ::: : :::@::: :::: ::::
| :: : @ : ::@:@# @ : : ::::: :: ::: :: :: ::: : :::@::: :::: :::::
| :: : @ : ::@:@# @ : : ::::: :: ::: :: :: ::: : :::@::: :::: :::::::
| :: : @ : ::@:@# @ : : ::::: :: ::: :: :: ::: : :::@::: :::: ::::::::
| :: : @ : ::@:@# @ : : ::::: :: ::: :: :: ::: : :::@::: :::: ::::::::@:
| :: : @ : ::@:@# @ : : ::::: :: ::: :: :: ::: : :::@::: :::: ::::::::@::
| :: : @ : ::@:@# @ : : ::::: :: ::: :: :: ::: : :::@::: :::: ::::::::@::
| :: : @ : ::@:@# @ : : ::::: :: ::: :: :: ::: : :::@::: :::: ::::::::@::
| :: : @ : ::@:@# @ : : ::::: :: ::: :: :: ::: : :::@::: :::: ::::::::@::
| :: : @ : ::@:@# @ : : ::::: :: ::: :: :: ::: : :::@::: :::: ::::::::@::
0 +----------------------------------------------------------------------->Gi
0 40.70

Number of snapshots: 58
Detailed snapshots: [4, 8, 10, 11 (peak), 12, 37, 54]


Mine hits the peak early on at 2MB and decreases steadily after, while guile hits the peak at the end with 3.5MB because it never frees memory (also it has a shitload of memory errors if you run it through valgrind --leak-check=full).

Name: Anonymous 2014-05-26 22:01

>>47
I kekked

Name: Anonymous 2014-05-26 23:43

>>48
Mazel tov! Does it get the right result though?

Name: Anonymous 2014-05-27 7:26

>>50
Yes.

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