head/tail implementation using protocol
another implementation inspired from python
/** | |
* so many type of chaining | |
*/ | |
//// about dot-indentation. | |
// type 1-1. align with dot. | |
const ret = obj.method1() | |
.method2() | |
.method3() | |
.value(); |
#!/usr/bin/env xcrun --sdk macosx10.10 swift -i | |
import Foundation | |
println("Usage: \n\t\t\(NSURL(string:__FILE__).lastPathComponent) -- [options]") | |
// #TODO options | |
var opt = Dictionary<String, String>() | |
for arg in Process.arguments { | |
let array = arg.componentsSeparatedByString("=") | |
let key: String? = array[0] |
/** | |
/// f가 리턴하기 전에 `x`가 사라지지 않았을 때만 `f(x)`를 평가하고 결과를 반환한다. | |
func withExtendedLifetime<T, Result>(x: T, f: (T) -> Result) -> Result | |
func withExtendedLifetime<T, Result>(x: T, f: () -> Result) -> Result | |
**/ | |
func getClosure() -> ()->() { | |
// http://nshipster.com/swift-comparison-protocols/ | |
import Foundation | |
struct CSSSelector { | |
let selector: String | |
struct Specificity { | |
let id: Int | |
let `class`: Int |
{ | |
"installed_packages": | |
[ | |
"AutoFileName", // 열려있는 디렉토리 기준으로 리소스의 경로 자동 완성 | |
"Better CoffeeScript", // CoffeeScript 추가 Snippet들 | |
"DashDoc", // Dash의 Snippet 연동 | |
"Diffy", // 2 Column으로 파일을 열면 비교 | |
"DocBlockr", // Doxygen 스타일 등의 주석 포맷 자동생성 | |
"Emmet", | |
"FixMyJS", // 뭔가 구림. 잘 안씀. |
// Expand all of followers and execute in console. | |
// [followers](https://twitter.com/followers) | |
var users = [].slice.call(document.querySelectorAll("div[data-test-selector=ProfileTimelineUser]")); | |
users.filter(function(user){ | |
return !user.querySelector("span.Icon--protected"); | |
}).map(function(user){ | |
user.parentNode.removeChild(user); | |
}); |
function code(name) { | |
return "0x" + name.charCodeAt(0).toString(16); | |
} | |
window.open("http://unicode.org/cldr/utility/character.jsp?a=00" + code(prompt())); |
I hereby claim:
To claim this, I am signing this object:
// https://www.cs.nott.ac.uk/~gmh/monparsing.pdf | |
// | |
// type Parser[T] = String -> [(T, String)] | |
// | |
/** lookahead token | |
* | |
* Parser -> Parser |