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
def accum[X,Y](seed: X, seq: Seq[Y])(fun: (X,Y) => X) = | |
seq.foldLeft(List[List[X]]()) { | |
case (Nil, y) => (fun(seed, y) :: Nil) :: Nil | |
case (buf, y) => (fun(buf.head.head, y) :: buf.head ) :: buf | |
} | |
(accum(0, (0 to 10)) { _ + _ }) foreach println |
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
Compiled from "SeqMatch.scala" | |
public final class SeqMatch$ { | |
public static final SeqMatch$ MODULE$; | |
public static {}; | |
Code: | |
0: new #2 // class SeqMatch$ | |
3: invokespecial #12 // Method "<init>":()V | |
6: return |
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
type l_str = List[String] | |
type extract = (String, l_str) | |
def reorder(list: l_str, before: Int, after: Int): l_str = { | |
val (value, temp_list) = delete_at(before, list) | |
insert_at(value, after, temp_list) | |
} | |
def delete_at(at: Int, down: l_str, top: l_str = Nil): extract = | |
if (at <= 0 || down.tail.isEmpty) (down.head, rewind(top, down.tail)) |
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
/* | |
* Copyright 2011 Midokura KK | |
*/ | |
package org.midonet.midolman.rules; | |
import java.util.Set; | |
import java.util.UUID; | |
import org.midonet.packets.IPAddr; |
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 | |
ip=$1 | |
(for i in {1..10} | |
do | |
iperf -f m -c $ip | egrep -o "[0-9]* Mbits/sec" | |
done) | awk ' | |
{ SUM+=$1; VAR += $1 * $1; print $1, "Mbits/sec" } | |
END { MEAN = SUM/NR; print MEAN, sqrt(VAR/NR - MEAN*MEAN) } |