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
@ load.ivy("com.lihaoyi" %% "fastparse" % "0.1.4") | |
@ import fastparse._ | |
import fastparse._ | |
@ val parser = P( "a".rep1.!.flatMap(s => ("b" * s.length) ~ ("c" * s.length)) ) | |
parser: fastparse.Parser[Unit] = parser | |
@ parser.parse("aaa") | |
res4: fastparse.core.Result[Unit] = Failure(parser:0 / "bbb":3 ..."", false) |
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
find ~ -name test3* -ok rm {}\; |
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
find ~ -name test3* -ok rm {}\; |
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 javax.sound.midi._ | |
val synth = MidiSystem.getSynthesizer() | |
synth.open() | |
def note(i: Int) = { | |
val channels = synth.getChannels() | |
channels(0).noteOn(i, 100) | |
Thread.sleep(250) | |
channels(0).noteOff(i) | |
} |
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
Welcome to Scala version 2.11.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_25). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import scala.reflect.macros.blackbox.Context; import scala.language.experimental.macros | |
import scala.reflect.macros.blackbox.Context | |
import scala.language.experimental.macros | |
scala> def applyImpl(c: Context)(expr: c.Expr[Unit]): c.Expr[Nothing] = { | |
| import c.universe._ |
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
Bad | |
def ++(xs: GenTraversableOnce[A]): ArrayBuffer[A] | |
def ++[B](that: GenTraversableOnce[B]): ArrayBuffer[B] | |
def ++:[B >: A, That](that: collection.Traversable[B])(implicit bf: CanBuildFrom[ArrayBuffer[A], B, That]): That | |
def ++:[B](that: TraversableOnce[B]): ArrayBuffer[B] | |
def +:(elem: A): ArrayBuffer[A] | |
def -(elem1: A, elem2: A, elems: A*): ArrayBuffer[A] | |
def -(elem: A): ArrayBuffer[A] | |
def --(xs: GenTraversableOnce[A]): ArrayBuffer[A] |
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
>>> class Foo: | |
... x = 1 | |
... y = (x, lambda: x) | |
... | |
>>> Foo().x | |
1 | |
>>> Foo().y | |
(1, <function <lambda> at 0x10754d0c8>) | |
>>> Foo().y[0] | |
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
>>> def foo(): | |
... x = 1 | |
... y = (x, lambda: x) | |
... return (x, y) | |
... | |
>>> foo()[1][1]() | |
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
>>> class Foo: | |
... x = 1 | |
... y = x | |
... print y | |
... class Bar: | |
... z = y | |
... print z | |
... | |
1 | |
Traceback (most recent call last): |
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
>>> a = 1 | |
>>> class Foo: | |
... a = 2 | |
... print a | |
... def bar(self): | |
... print a | |
... | |
2 | |
>>> Foo().bar() | |
1 |