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
int _twoExponential(int exponent, int acc) { | |
if ( exponent == 0 ) { | |
return acc; | |
} | |
acc *= 2; | |
return _twoExponential(--exponent, acc); | |
} | |
int exponential(int num) { |
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
public class EqualTest{ | |
public static void main(String []args){ | |
new EqualTest().test(); | |
} | |
private void test() { | |
Dummy obj1 = new Dummy(1, 10.0); | |
Dummy obj2 = new Dummy(2, 20.0); | |
Dummy obj3 = new Dummy(1, 10.0); | |
System.out.println("obj1 == obj2: " + (obj1 == obj2) + " / obj1.equals(obj2): " + obj1.equals(obj2) ); |
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
case class Dummy(a: Int, b: Double) | |
val obj1 = Dummy(1, 10.0) | |
val obj2 = Dummy(2, 20.0) | |
val obj3 = Dummy(1, 10.0) | |
obj1 == obj2 | |
obj1 equals obj2 | |
obj1 == obj3 |
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
// 스칼라의 문법인 케이스 클래스와 패턴 매칭 코드로 살펴보기 | |
// regular, non-encapsulated data structures 가 필요할 때 케이스 클래스 사용 | |
// Programming In Scala 15장 예제 코드로 구성 됨 | |
abstract class Expr | |
case class Var(name: String) extends Expr | |
case class Number(num: Double) extends Expr | |
case class UnOp(operator: String, arg: Expr) extends Expr | |
case class BinOp(operator: String, left: Expr, right: Expr) extends Expr |
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
# Install Homebrew | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
# Install nvm | |
brew install nvm | |
# Export nvm environment | |
export NVM_DIR="$HOME/.nvm" | |
. "$(brew --prefix nvm)/nvm.sh" |
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
// 0 is the first line from the lookAndSay result. | |
fun ant(line: Int): String { | |
var resultString = "1" | |
var lineCounter = line | |
while (lineCounter-- > 0) { | |
var tempBuffer = StringBuilder() | |
var curCompareChar = resultString[0] | |
var curCnt = 1 | |
for (idx in 1..resultString.length - 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
# Set variables in .bashrc file | |
# don't forget to change your path correctly! | |
export GOPATH=$HOME/golang | |
export GOROOT=/usr/local/opt/go/libexec | |
export PATH=$PATH:$GOPATH/bin | |
export PATH=$PATH:$GOROOT/bin |
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
# Reuse an existing ssh-agent on login, or create a new one. Append this to your .bashrc | |
# I have no idea who the author of the original concept was for reusing agents. This | |
# version also handles the case where the agent exists but has no keys. | |
GOT_AGENT=0 | |
for FILE in $(find /tmp/ssh-* -type s -user ${LOGNAME} -name "agent.[0-9]*" 2>/dev/null) | |
do | |
SOCK_PID=${FILE##*.} |