Kurzes Snippet:
extendedEuclidean :: Int -> Int -> (Int, Int, Int) extendedEuclidean a b = if b == 0 then (a, 1, 0) else (d, t, s - (a `div` b) * t) where (d, s, t) = extendedEuclidean b (a `mod` b)
Kurzes Snippet:
extendedEuclidean :: Int -> Int -> (Int, Int, Int) extendedEuclidean a b = if b == 0 then (a, 1, 0) else (d, t, s - (a `div` b) * t) where (d, s, t) = extendedEuclidean b (a `mod` b)
Kurzer JavaScript Code-Snippet, um Duplikate aus einem JavaScript-Array zu entfernen:
/** * Remove duplicates from array * */ var removeDuplicates = function(t) { t.sort(); var elems = {}; var newArray = []; for (var i = 0, len = t.length; i < len; i++) { elems[t[i]] = 0; } for (var elem in elems) { newArray.push(elem); } return newArray; };