This file contains 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
(defn balance [node] | |
(match [node] | |
[( [:black [:red [:red a x b] y c] z d] | |
| [:black [:red a x [:red b y c]] z d] | |
| [:black a x [:red [:red b y c] z d]] | |
| [:black a x [:red b y [:red c z d]]] | |
)] | |
[:red [:black a x b] y [:black c z d]] | |
:else | |
node)) |
This file contains 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.Arrow | |
import Control.Applicative | |
import Control.Monad.Instances | |
import Data.List (genericLength) | |
import Data.Foldable | |
import Data.Function | |
avg_fold xs = |
This file contains 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
awk '/.*7fff.*/{print $4 " " $6}' |
This file contains 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 System.Cmd | |
import System.FilePath.Posix | |
import System.IO.HVFS | |
import System.IO.HVFS.Utils | |
copyFiles :: String -- prefix | |
-> FilePath -- destination dir | |
-> [FilePath] -- files to copy | |
-> IO () |
This file contains 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
// Kevin Cantu | |
// December 2011 | |
/* | |
fn sendfn lambda block | |
closures no immutable immutable mutable | |
keyword def yes no no no e.g., fn xyz () {...} |
This file contains 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
// Kevin Cantu | |
// December 2011 | |
// why do the types, fn(), sendfn(), lambda(), and block() require parens? | |
// why isn't there a way to name a block? | |
// why isn't there a top level equivalent to fn for each of the others? | |
use std; |
This file contains 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
use std; | |
fn usingSendfn ( f : sendfn() ) { | |
f(); | |
} | |
fn main (args: [str]) { | |
usingSendfn ({|| std::io::println ("this is block syntax..."); }); // segfault | |
} |
This file contains 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 | |
# runrust: compile and run rust source code | |
# | |
# Kevin Cantu (c) 2011 ==> free use and modification, no warranty, enjoy! | |
if [[ ! "${1#*.}" == "rs" ]] | |
then | |
ME="$(basename "$0")" | |
echo "Usage: $ME rust-source-file.rs" | |
exit 1 |
This file contains 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
// Kevin Cantu | |
// basic Rust function behavior | |
/* | |
fn sendfn lambda block | |
closures no immutable immutable mutable | |
keyword def yes no no no e.g., fn xyz () {...} |
This file contains 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
use std; | |
use vec2; | |
// OK this both compiles and works as expected! | |
// BEFORE(aa): [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] | |
// AFTER (dd): [0x04030201, 0x08070605] | |
// compare with libstd/io.rs at 77-84 (fn read()) | |
#[test] |