- laske (3+4/5)*6
- kutsu funktiota get argumenteilla “ciao” ja 1
- määrittele vektori jossa on elementit 1, “moi” ja true
- määrittele vektori joka sisältää keywordit :diff ja :merge
- määrittele map jossa avain 1 liittyy arvoon “hei” ja avain :key arvoon [13 7]
- määrittele muuttuja my-map joka sisältää mapin {1 2}. Lisää
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 qualified Data.Map as M | |
| import qualified Data.Set as S | |
| import Data.List.Split | |
| import Data.List | |
| data Range = Range (Int,Int) (Int,Int) | |
| data Command = On Range | Off Range | Toggle Range | |
| type Lights = S.Set (Int,Int) | |
| inRange :: Range -> Lights |
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
| #!/bin/sh | |
| jq -c 'recurse(.[]? | select((type!="object") or (to_entries | map(.value) | contains(["red"]) | not))) | numbers' < input.12 | awk '{ans += $1} END { print ans }' |
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 TypeFamilies, TypeOperators #-} | |
| data A | |
| data B | |
| data C | |
| -- You can define type-level polynomial expressions using :*: and :+: | |
| data a :*: b | |
| data a :+: 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
| ghci> let manyThen x end = choice [(:) <$> x <*> manyThen x end, const [] <$> end] | |
| ghci> parseOnly (manyThen anyChar (char ':')) (pack "he:llo:") | |
| Right "he:llo" |
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 example) | |
| (set! *warn-on-reflection* true) | |
| (definterface Foo | |
| (frobnicate []) | |
| (mogrify [x y])) | |
| (defn ^Foo fake-Foo [] | |
| (let [state-a (atom {:frobnicate 1 :data []})] |
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
| *Main> take 10 ramanujan | |
| [1729,4104,13832,20683,32832,39312,40033,46683,64232,65728] | |
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
| class Unsound { | |
| static class Constrain<A, B extends A> {} | |
| static class Bind<A> { | |
| <B extends A> A upcast(Constrain<A,B> constrain, B b) { | |
| return b; | |
| } | |
| } | |
| static <T,U> U coerce(T t) { | |
| Constrain<U, ? super T> constrain = null; | |
| Bind<U> bind = new Bind<U>(); |
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
| *Main> paths 3 | |
| [[1],[2,1],[3,2,1],[3,1],[2,3,1],[2],[3,1,2],[3,2],[3]] | |
| *Main> paths 4 | |
| [[1],[2,1],[3,2,1],[4,3,2,1],[4,2,1],[3,4,2,1],[3,1],[2,3,1],[4,2,3,1],[4,3,1],[2,4,3,1],[4,1],[2,4,1],[3,2,4,1],[3,4,1],[2,3,4,1],[2],[3,1,2],[4,3,1,2],[4,1,2],[3,4,1,2],[3,2],[4,1,3,2],[4,3,2],[4,2],[3,1,4,2],[3,4,2],[3],[4,2,1,3],[4,1,3],[4,1,2,3],[4,2,3],[4,3],[4]] |
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
| #!/bin/bash | |
| set -xe | |
| iface=wwp0s20f0u2i12 | |
| modem=$(mmcli -L | grep -o '/org/freedesktop/[^ ]*') | |
| case $1 in | |
| up) |