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-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.

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