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
val o: Observable[Int] = Observable(1 to 20) | |
def bufferByKey[T, K](o: Observable[T], keyFunc: T => K): Observable[Seq[T]] = { | |
type S = (Option[K], List[T], Option[List[T]]) | |
o.scan[S](None, List(), None) { (lastState: S, newVal: T) => | |
val (lastKey, acc, emit) = lastState | |
val nk = keyFunc(newVal) | |
lastKey match { | |
case None => (Some(nk), newVal :: acc, None) | |
case Some(k) => |
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 bufferByKey[T, K](o: Observable[T], keyFunc: T => K): Observable[Seq[T]] = { | |
type S = (Option[K], List[T], Option[List[T]]) | |
o.scan[S](None, List(), None) { (lastState: S, newVal: T) => | |
val (lastKey, acc, emit) = lastState | |
val nk = keyFunc(newVal) | |
lastKey match { | |
case None => (Some(nk), newVal :: acc, None) | |
case Some(k) => | |
if (k == nk) | |
(Some(k), newVal :: acc, None) |
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
hello world |
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
hello world |
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 time | |
import control | |
import matplotlib.pyplot as plt | |
from jax import random | |
from jax import jit | |
from jax import value_and_grad | |
from jax import lax | |
from jax import vmap | |
import jax.numpy as jp | |
from jax.experimental import stax |
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 time | |
import control | |
import matplotlib.pyplot as plt | |
from jax import random | |
from jax import jit | |
from jax import value_and_grad | |
from jax import lax | |
from jax import vmap | |
import jax.numpy as jp | |
from jax.experimental import stax |
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 time | |
import control | |
import matplotlib.pyplot as plt | |
from jax import random | |
from jax import jit | |
from jax import value_and_grad | |
from jax import lax | |
from jax import vmap | |
import jax.numpy as jp | |
from jax.experimental import stax |
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 time | |
import control | |
import matplotlib.pyplot as plt | |
from jax import random | |
from jax import jit | |
from jax import value_and_grad | |
from jax import lax | |
from jax import vmap | |
import jax.numpy as jp | |
from jax.experimental import stax |
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 time | |
import control | |
import matplotlib.pyplot as plt | |
from jax import random | |
from jax import jit | |
from jax import value_and_grad | |
from jax import lax | |
from jax import vmap | |
import jax.numpy as jp | |
from jax.experimental import stax |
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 time | |
import control | |
import matplotlib.pyplot as plt | |
from jax import random | |
from jax import jit | |
from jax import value_and_grad | |
from jax import lax | |
from jax import vmap | |
import jax.numpy as jp | |
from jax.experimental import stax |
OlderNewer