Skip to content

Instantly share code, notes, and snippets.

View sohnryang's full-sized avatar
🍟
Potato inside

Ryang Sohn sohnryang

🍟
Potato inside
View GitHub Profile
@sohnryang
sohnryang / HelloWorld.cpp
Created October 29, 2016 05:04
A C++ Hello World
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!" << endl;
return 0;
}
@sohnryang
sohnryang / .vimrc
Last active October 8, 2017 08:06
my .vimrc (or nvim init.vim)
syntax on
set nu
set relativenumber
set ts=4
set shiftwidth=4
"packages
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-fugitive'
@sohnryang
sohnryang / exercise.scala
Last active January 30, 2017 22:25
scala for the impatient - making random BigInt to base 36 string
BigInt probablePrime(100, Random) toString(36)
@sohnryang
sohnryang / exercise.scala
Last active January 31, 2017 22:12
scala for the impatient - get first & last character
val str = "ABCD"
//First character
println(str(0))
//Last character
println(str takeRight 1)
@sohnryang
sohnryang / signum.scala
Created January 31, 2017 02:07
scala for the impatient - calculating signum
def signum(x: Int) = {
if (x > 0) 1
else if (x < 0) -1
else 0
}
@sohnryang
sohnryang / exercise.scala
Last active January 31, 2017 22:15
scala for the impatient - Come up with one situation where the assignment x = y = 1 is valid in Scala
var x: Unit = ()
var y: Int = 0
x = y = 1
@sohnryang
sohnryang / backwardLoop.scala
Created January 31, 2017 22:20
scala for the impatient - loop backward
for (i <- 10 to 1 by -1) println(i)
@sohnryang
sohnryang / countdown.scala
Created January 31, 2017 22:25
scala for the impatient - writing countdown procedure
def countdown(n: Int) {
for (i <- n to 0 by -1) println(i)
}
@sohnryang
sohnryang / product_unicode.scala
Created January 31, 2017 22:33
scala for the impatient - product of unicode
val str = "Test"
str.foldLeft(1L)(_ * _.toInt)
@sohnryang
sohnryang / product.scala
Last active January 31, 2017 22:37
scala for the impatient - writing function product()
def product(s: String): Long = {
s.foldLeft(1L)(_ * _.toInt)
}