This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tämä on yksinkertaisempi mutta generoi nollia | |
import java.util.Random; | |
import java.util.Arrays; | |
public class Lol { | |
public static void main(String[] args) { | |
int K=10; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setti3-043.LukujenSumma vaik: 1,30 opet: 2,40 n: 10 | |
setti3-044.Pienin vaik: 1,25 opet: 2,88 n: 8 | |
setti3-045.Suurin vaik: 2,20 opet: 3,60 n: 5 | |
setti3-046.LukujenKeskiarvo vaik: 1,86 opet: 3,14 n: 7 | |
setti3-047.NimenPituus vaik: 2,80 opet: 4,00 n: 5 | |
setti3-048.EnsimmainenKirjain vaik: 1,67 opet: 3,33 n: 6 | |
setti3-049.ViimeinenKirjain vaik: 1,71 opet: 2,57 n: 7 | |
setti3-050.EnsimmaisetKirjaimet vaik: 2,88 opet: 2,75 n: 8 | |
setti3-051.KirjaimetErikseen vaik: 3,33 opet: 3,50 n: 6 | |
setti3-052.NimenKaantaminen vaik: 3,43 opet: 3,29 n: 7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE ViewPatterns #-} | |
check p x = if p x | |
then x | |
else error "check failed!" | |
positive = (>0) | |
intDivide :: Int -> Int -> Int | |
intDivide x (check positive -> y) = x `div` y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo :: [a] -> [[a]] | |
foo (x:xs) = do z <- xs | |
-- nyt z :: a koska xs :: [a] | |
gnng <- foo xs | |
-- nyt gnng :: [a] koska foo xs :: [[a]] | |
return $ [z]++gnng | |
-- tämä on oikein koska [z]++gnng :: [a] ja foo:n paluutyyppi on [[a]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ foo="" | |
$ bar="x" | |
$ if [ -n $bar ]; then echo MOI; else echo HEI; fi | |
MOI | |
$ if [ -n $foo ]; then echo MOI; else echo HEI; fi | |
MOI | |
$ [ $bar = $foo ] | |
[: 6: =: argument expected | |
$ [ "$foo" = "$bar" ] | |
$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- statusd_mybatt.lua | |
-- | |
-- Author | |
-- Joel Kaasinen | |
if not statusd_mybatt then | |
statusd_uptime={ | |
interval=60*1000, | |
} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[endo:~]% ls /sys/class/power_supply/BAT0 | |
alarm energy_full manufacturer power_now status type voltage_now | |
cycle_count energy_full_design model_name present subsystem uevent | |
device energy_now power serial_number technology voltage_min_design |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns q) | |
(defn empty-queue [] | |
(atom [::invalid])) | |
(defn push! [q val] | |
(swap! q conj val)) | |
(defn pop! [q] | |
(first (swap! q subvec 1))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(pprint (macroexpand-1 '(ns foo (:use a) (:require b) (:import c)))) | |
==> | |
(do | |
(clojure.core/in-ns 'foo) | |
(clojure.core/with-loading-context | |
(clojure.core/refer 'clojure.core) | |
(clojure.core/use 'a) | |
(clojure.core/require 'b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Parallel.Strategies | |
factorial :: Integer -> Integer | |
factorial n = product [1..n] | |
f = length . show . factorial | |
main = print result | |
where result = map f [n+100,n+99..n] `using` parList rseq | |
n = 50*1000 |
OlderNewer