View .bashrc
# 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
View LookAndSay.kt
// 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) {
View install.sh
# 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"
View CaseClass.scala
// 스칼라의 문법인 케이스 클래스와 패턴 매칭 코드로 살펴보기
// 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
View Equaltest.scala
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
View EqualTest.java
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) );
View tail_rec_exp.c
int _twoExponential(int exponent, int acc) {
if ( exponent == 0 ) {
return acc;
}
acc *= 2;
return _twoExponential(--exponent, acc);
}
int exponential(int num) {
View Rational.scala
package nfm.ex06
/**
* Programming In Scala 2/e List 6.5 코드
* 분수 Class
* @param n 분자
* @param d 분모
*/
/* 스칼라에 있는 문법: Class에서 기본 생성자 선언 가능
View temp.ino
float tempC;
int reading;
int tempPin = 0;
void setup()
{
Serial.begin(9600);
analogReference(INTERNAL);
}
void loop()
{