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
/// List implementation | |
enum List<A> : CustomStringConvertible { | |
case empty | |
indirect case list(A, List<A>) | |
public var description: String { | |
return "List:{\(descriptionMeta)" | |
} | |
fileprivate var descriptionMeta: 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
precedencegroup SequenceProcessing { | |
associativity: left | |
} | |
infix operator --> : SequenceProcessing | |
infix operator -/> : SequenceProcessing | |
infix operator -!> : SequenceProcessing | |
public func --> <A:Sequence, E, B> (lhs: A, rhs:(E) -> B) -> [B] | |
where A.Iterator.Element == E { |
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
//: http://swiftlang.ng.bluemix.net/#/repl/5829e17246872154466a8b0b | |
var state = (0, 1) | |
let fib = sequence(state: state){ (state: inout (Int, Int)) -> Int? in | |
defer { state = (state.1, state.0 + state.1) } | |
return state.0 | |
} | |
for f in fib.prefix(11) { |
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 UIKit | |
import PlaygroundSupport | |
class PlayViewController: UIViewController { | |
// 손을 끌고 다닐 뷰 | |
lazy var draggableView: UIView = { | |
let v = UIView(frame: CGRect(x:40, y:40, width:50, height: 50)) | |
v.backgroundColor = UIColor.blue() | |
return v | |
}() |
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 Foundation | |
let samples = ["AAAA", "BBBBB", "ABABABAB", "BABABA", "AAABBB"] | |
extension String { | |
var fullRange: NSRange { | |
return NSRange(location: 0, length: characters.count) | |
} | |
} |
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
#!/bin/bash | |
### plug.vim (https://github.com/junegunn/vim-plug)의 | |
### 메인 플러그인 파일을 간단하게 업데이트한다. | |
### 실제 버전업 여부는 확인하지 않으며 | |
### 최종 실행일자가 오늘 이전이면 무조건 다운로드한다. | |
# 가장최근업데이트 기록을 찾는다. | |
# 없으면 000000 이 최종 기록이다. | |
UD=`basename $(ls -1 *.update | sort -r | head -1) .update` | |
if [[ x$UD == x ]]; then UD=000000.update;fi |
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 Foundation | |
enum SQLite3Error : Error { | |
case connectionError(String) | |
case queryError(String) | |
case valueError(String) | |
case otherError(String) | |
} | |
class SQLite3Conn { |
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
BOARD_SIZE = 8 | |
class Vertex: | |
"""그래프 구성을 위한 꼭지점 클래스""" | |
def __init__(self, key): | |
self._id = key | |
self.connectedVertices = {} | |
def addNeighbor(self, nbr, weight=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
COLORS = dict(zip(range(1, 10), 'black red green yellow blue magenta' | |
' cyan white reset'.split())) | |
class BG: | |
black = '\033[40m' | |
red = '\033[41m' | |
green = '\033[42m' | |
yellow = '\033[43m' | |
blue = '\033[44m' |
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
C_DEFAULT='\033[m' | |
C_WHITE='\033[1m' | |
C_BLACK='\033[30m' | |
C_RED='\033[0;31m' | |
C_GREEN='\033[32m' | |
C_YELLOW='\033[33m' | |
C_BLUE='\033[0;34m' | |
C_PURPLE='\033[35m' | |
C_CYAN='\033[36m' | |
C_LIGHTGRAY='\033[37m' |