Programmiersprachen (Re: [linux-l] Ruby: sehr cool, aber laaaahm... wie geht's schneller?! - D?)

David Hansen david.hansen at physik.fu-berlin.de
So Aug 27 15:54:40 CEST 2006


On Sun, 27 Aug 2006 12:43:21 +0200 Ivan F. Villanueva B. wrote:

> Ich würde es gerne in Perl, Rubby, Python, Ocalm und D sehen.

Noch ein Kompromiss Angebot an die Anhänger der Funktionalen
und Imperativen Programmierung (Lua):

dx = .0001

function square (x) return x*x end
function cube (x) return x*x*x end

funs = { sin = math.sin, cos = math.cos, square = square, cube = cube }

function steps (x0, x1, d)
    return function (_, x)
               return (x1 > x and x + d) or nil
           end, nil, x0-d
end

for n, f in pairs (funs) do
    local function df (x) return (f(x+dx/2) - f(x-dx/2))/dx end

    print (n)
    for x in steps (0, 3, .1) do
        print (" [", x, ", ", f(x), ", ", df (x),  "]")
    end
    print ("\n")
end




Mehr Informationen über die Mailingliste linux-l