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
| def shorten(s: String): String = { | |
| var input = s | |
| var done = false | |
| var i = 0 | |
| while (!done) { | |
| val char = input.charAt(i) | |
| val nextChar = input.charAt(i + 1) | |
| if ((char.toChar - nextChar.toChar).abs.toInt == 32) { |
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
| object DTALC { | |
| } |
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
| package ch6 | |
| import scala.util.matching.Regex | |
| object ParserTesting { | |
| sealed trait ParseResult[+A, +F] | |
| case class ParseSuccess[A](parsed: A, unparsed: String) extends ParseResult[A, Nothing] | |
| case class ParseFailure[F](error: F) extends ParseResult[Nothing, F] |
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
| package xml; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import com.jantox.xmlparser.Scanner; | |
| /* | |
| * <xmlNode> ::= "<" ~ <name> ~ ">" ~ <body> ~ "</" ~ <name> ">" | |
| * <letter> ::= [A-Za-z] |
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 React from 'react'; | |
| import deepcopy from 'deepcopy'; | |
| let RouterLink = React.createClass({ | |
| propTypes: { | |
| to: React.PropTypes.string.isRequired, | |
| params: React.PropTypes.object, | |
| activeClassName: React.PropTypes.string |
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 React from 'react'; | |
| class Router extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| routes: props.routes, | |
| path: "index", | |
| params: {} |
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
| data AST a = Value a | Operation (a -> a -> a) (AST a) (AST a) | |
| evaluate :: (Num a) => (AST a) -> a | |
| evaluate (Value a) = a | |
| evaluate (Operation o a b) = evaluate a `o` evaluate 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
| class Writer[A](runWriter: (A, String)) { | |
| def apply(x: (A, String)): Writer[A] = new Writer[A](x) | |
| def run = runWriter | |
| def flatMap[B](x: A => Writer[B]): Writer[B] = { | |
| val (a: A, b: String) = runWriter | |
| val (y: B, z: String) = x(a).run |
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
| package com.jantox.dungmast; | |
| public class Vector2D { | |
| public double x, y; | |
| public Vector2D() { | |
| x = y = 0; | |
| } | |
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
| // pitch and yaw are in degrees | |
| Vector3D getDirectionVector() { | |
| return new Vector3D(-Math.cos(pitch * Math.PI / 180.0) * Math.sin(yaw * Math.PI / 180.0), Math.sin(pitch * Math.PI / 180.0), -Math.cos(pitch * Math.PI / 180.0) * Math.cos(yaw * Math.PI / 180.0)); | |
| } |