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

Software pushups

Name: Anonymous 2014-11-24 23:01

Let's exercise together, /prog/!

1) Write a subroutine that accepts an array of unsigned ints and returns 4. It must operate on the array in-place and partition it so that all nonzero values are at the beginning of the array, and all zero values are moved to the end. For example, the input [0, 2, 0, 0, 4, 1, 4, 5] could be changed to [2, 4, 1, 4, 5, 0, 0, 0]. The relative order of the nonzero values is unimportant.

Name: Anonymous 2014-12-05 22:49

>>71
maybe try posting one that isn't a sorting problem

Name: Anonymous 2014-12-05 23:20

OK. Write a program that check's >>77-kun's dubs.

Name: Anonymous 2014-12-06 2:24

function subroutine(ints) {
return ints.sort().reverse();
}

Name: Anonymous 2014-12-06 10:40

JACKSON 80 GET!

Name: Anonymous 2014-12-07 20:58

>>78
dubcek = check . reverse . show . num
where check (x : y : ys) | x == y = Dubs
check _ = Jackson5Get

Name: Anonymous 2014-12-08 5:31

>>78
function checkem(table, post)
for jackson82get, value in pairs(table) do
if value == post then print("Checked: Nice, bro xD")
else error("HIBT?")
end
end
end

dubs = {11, 22, 33, 44, 55, 66, 77, 88, 99}
print(checkem(dubs, 77))

Name: Anonymous 2014-12-08 12:47

I'm disappointed to only see solutions to >>1 in various pleb languages.

int f(std::vector<unsigned> & v)
{
std::partition(v.begin(), v.end(), [](unsigned it) { return it; });
return 4;
}

Name: Anonymous 2014-12-08 13:06

>>83
So your solution is to dump more shit on the pile?

Name: Anonymous 2014-12-08 13:24

>>83
std::
std::

Ever heard of using namespace std;, peasant?

Name: Anonymous 2014-12-08 14:58

>>85
using namespace std;
void main(void)
{
get(AIDS);
}

Name: Anonymous 2014-12-08 15:02

>>78
Number isDubs := method(
t := self asString
if(t at (t size -1) == t at(t size -2),
Exception raise("checkem"),
false));

Name: Anonymous 2014-12-08 16:41

>>87
is that io

Name: Anonymous 2014-12-08 16:43

>>85
Considered harmful and polluting.

Name: Anonymous 2014-12-08 16:53

>>89
Lolwut? Sepples retards are too stupid to even have a prelude? No wonder sepples code looks like

std::std::std::std::std::std<std::std::std::<std::<std::>std::>std::std::std::>

Name: Anonymous 2014-12-08 17:03

>>88
Why does someone always ask that?

Name: Anonymous 2014-12-08 18:34

>>91
Because he has dusb.

Name: Anonymous 2014-12-08 18:54

>>88
Yeah.

Io> 88 isDubs

Exception: checkem
---------
Exception raise Command Line 1
Number isDubs Command Line 1

Io>

Name: Anonymous 2014-12-08 21:44

>>91
Because from this distance it's hard to tell. It might turn out to be Titan, or Europa...

Name: Anonymous 2014-12-08 22:31

>>94
Anonymous liked this comment.

Name: Anonymous 2014-12-09 21:53

*pushes up your software* :o)

Name: Anonymous 2014-12-10 0:05

>>96
Thanks, it really needed a lift =.)

Name: Anonymous 2014-12-24 16:58

BUMP BEFORE DEADLINE AAAHH

Name: Anonymous 2014-12-24 17:40

check 'em

Name: Anonymous 2014-12-24 17:47

>>99
Nice.

Name: Anonymous 2014-12-24 21:10

>>100
More like Ve-nice to me.

Name: Anonymous 2014-12-24 21:13

>>54
That really depends.

If you can write cpu-dependent code, unless it's an extremely complex instruction set with difficult to predict performance, beating a compiler isn't hard.

Name: Anonymous 2014-12-25 1:48

>>102
a.k.a. IA64
Swallow it, Cudder-sama.

Name: Anonymous 2014-12-25 2:09

function one(v)
i = 1
j = #v
while i ~= j do
while i < j and v[i] ~= 0 do i = i + 1 end
while j > i and v[j] == 0 do j = j - 1 end
v[i], v[j] = v[j], v[i]
end
end

Name: Cudder !MhMRSATORI 2014-12-25 2:57

>>102,103
>>57

>>71
{insert mergesort here with comparison replaced by random choice}

Name: Anonymous 2014-12-25 5:59

>>104
didnt expect to see a merges ort in fortran (:

Name: Anonymous 2014-12-25 8:39

>>103

woowee woowee woowee chan
woowee woowee woowee chan

Name: Anonymous 2014-12-25 13:47

>>105
Not falling for you, sorry.
Anyway, I do believe talented humans can beat compilers.
But that is just for now, you know.
Even if we suck at designing optimal code, collaborative optimization is a real possibility.
Sorry again, Cudder-sama.
Since ENTERPRISE SCALABLE TURN-KEY SOLUTIONS days I am still in love with what you appears to be. To me at least.
But that is just a "feeling" tailored for dysfunctional austistic homo mental midgets. Like I am. Exactly this. Do not even care.

>>107
Dear Sir or Madam,
I cannot understand what are you talking about.
Please explain in more appropriate terms, so we can have efficient communication.
Yours truly,
;;;;;;;;;;;;;;;;;

Btw.
Merry X-mas /prog/.
I did never was fit in here.
But it was what I could almost call "home".
That compiler for the idiot unknown language is doing fine, btw.
progrider admin is gentle person. Almost a hero. Saved /prog/ from the iminent oblivion.
tdavis has more followers than I initially thought. I met one last week. Surprise, surprise.
Maybe I should do something for templeos. Maybe SID emulation?
No need to know.
Lord sends us people to where we belong.
If I came to /prog/, there is something I need to do in here.
God sent me.
I do not even believe that much in God.
But maybe just believe that much in God.
Who knows?
What can be done is not what was done in the end.
Do more. Talk less.
Work hard.
Play hard.
All work and no play makes Jack a dull boy.

Name: Anonymous 2014-12-25 15:20

>>108
merry xmas

Name: Anonymous 2014-12-25 15:25

>>108
14:47
Ooh, nice 4:4 dubs.

Name: Anonymous 2014-12-25 15:56

Check em

Name: Anonymous 2014-12-25 21:23

func pushup(in []uint) {
idx := 0
lim := len(in)-1
for ;idx < lim; idx = idx + 1 {
if in[idx] == 0 {
in[idx] = in[lim]
in[lim] = 0
lim = lim - 1
}
}
}

Name: Anonymous 2014-12-26 17:25

>>112
try to pushup 0,1,0
Almost there, 22:23.

Name: Anonymous 2014-12-26 18:06

https://github.com/rtsisyk/luafun
Lua Fun is a high-performance functional programming library designed for LuaJIT tracing JIT compiler.
Let's see an example:
require 'fun'()
n = 100
print(reduce(operator.add, 0, map(function(x) return x^2 end, range(n))))

Just try to run the example above with luajit -jdump and see what happens:
-- blah blah blah...
->LOOP:
0bcaffd0 movaps xmm5, xmm7
0bcaffd3 movaps xmm7, xmm1
0bcaffd6 addsd xmm7, xmm5
0bcaffda ucomisd xmm7, xmm0
0bcaffde jnb 0x0bca0024 ->5
0bcaffe4 movaps xmm5, xmm7
0bcaffe7 mulsd xmm5, xmm5
0bcaffeb addsd xmm6, xmm5
0bcaffef jmp 0x0bcaffd0 ->LOOP
---- TRACE 1 stop -> loop


Embrace yourselves. v2.1 is coming.

Name: Anonymous 2014-12-26 19:09

>>114
That's seriously amazing. And this is coming out of lua of all languages.

Name: sage 2014-12-26 19:31

>>114
And they say Lisp has bad syntax.

Name: Anonymous 2014-12-26 20:57

>>114,115
That's stream fusion and SSE2. What's so impressive? Pure maps and reduces are trivial to optimize.

Name: Anonymous 2014-12-27 0:35

>>115
Not surprising.
http://dis.4chan.org/read/prog/1327456061
http://lambda-the-ultimate.org/node/3851
http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/doc/hopl.pdf
You take a thought language and VM model and give it to someone who knows what to do with it: LuaJIT in <1M.
You take a 3day-thought language without VM model and give it to engineering people: V8 in <10M.
You take a 3year-thought language and VM model and give it to enterprise people: JVM in <100M.
Their performance is on the same level, born around the same time too. (Lua in 1993, JS in 1995, Java in 1995).
Should I mention Python (1991), Ruby(1993) or PHP(1995)?
Should I remember Caml (1987) or Perl (1987) or the SICP itself (1985)?
It feels like people did not read their SICPs for decades, went cooking potatoes on the ascending x86 architecture, and then fed it to their children.
Result nowadays: half-digested Javashit everywhere - and people loving all of it! Because it is the best? There are no options?

No. It is just people love junk food.

>>116
Syntax is irrelevant, Lisp has none. Your options:
Lots of it? http://moonscript.org/
Or macros and make some? http://metalua.luaforge.net/
Or fuck that and make an entire OS? http://terralang.org/

>>117
Choose your destiny:
:(
:)

Name: Anonymous 2014-12-27 11:47

>>118
Syntax is very important. It means the difference between unreadable shit and maintanable code.

Also, Lisp has syntax. For instance, in Common Lisp a function is defined like this (defun foo (args)), while in Scheme it is defined like (define (foo args)). One has to remember in which dialect the function goes inside the brackets and in which it stays outside.

Name: Anonymous 2014-12-27 13:33

>>119
But `defun` is a macro, not a syntax!

Name: Anonymous 2014-12-27 13:58

>>120
Macros are syntax transformers.

Name: Anonymous 2014-12-27 13:59

>>118
I think the real problem is that none of them read their TAPL and so all those languages' type systems are shit.

Name: Anonymous 2014-12-27 15:30

>>118
You misunderstand, I really don't get what's impressive about it. Not many languages might do these simple optimizations, but that doesn't change the fact that they are basic.

Name: Anonymous 2014-12-29 7:32

>>121
Macros can have side effects too. They are extensions of the compiler.

>>123
A basic algorithm is more impressive than a complex one, provided they do the same thing.

Name: Anonymous 2014-12-29 11:27

>>113

how about now?

func pushup(in []uint) {
lim := len(in)-1
for idx := 0; idx < lim; idx = idx + 1 {
for ;lim >= 0 && in[lim]==0;lim = lim-1 {
}
if lim <= idx {
return
}
if in[idx] == 0 {
in[idx] = in[lim]
in[lim] = 0
lim = lim - 1
}
}
}

Name: Anonymous 2014-12-29 17:52

>>105
I'm just speaking from my experience. I've never done x86, but beating compilers on the 68k is pretty easy.

Name: Anonymous 2015-01-05 16:37

can we just bump the old thread tyvm

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