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
declare global { | |
interface Window { | |
projectName?: { | |
action: (message: string) => void; | |
}, | |
webkit?: { | |
messageHandlers?: { | |
projectName?: { | |
postMessage?: (message: any) => void | |
} |
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
// 1. Set도 동작하게 | |
// 2. Map도 동작하게 | |
// 3. inline 함수에 대해 조사한 뒤 최대 반영 | |
// 4. 어떤 클래스에 toJSON():String 메소드가 있다면 그 메소드를 통해 stringify를 하게 하시오 | |
@Target(AnnotationTarget.PROPERTY) | |
annotation class Ex // 제외할 속성 | |
@Target(AnnotationTarget.PROPERTY) | |
annotation class Name(val name: String) // json용 별도 이름지정 |
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
val trim = """[^.\d-+*/()]""".toRegex() | |
fun trim(v: String): String = v.replace(trim, "") | |
fun repMMtoP(v: String) = v.replace("--", "+") | |
fun repMtoPM(v: String) = v.replace("-", "+-") | |
val groupMD = """((?:\+|\+-)?[.\d]+)([*/])((?:\+|\+-)?[.\d]+)""".toRegex() | |
tailrec fun removeMultiDiv(v: String): String = groupMD.find(v).let { | |
if (it != null) { | |
val (target, left, op, right) = it.groupValues | |
val leftValue = left.replace("+", "").toDouble() |
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
protocol Paper2 { func run() throws -> [Program] } | |
protocol AnyProgrammer { | |
func makeProgram() throws -> Program | |
} | |
protocol Programmer2: AnyProgrammer { | |
associatedtype T: Paper2 | |
// Programmer는 Director에게 Paper를 제공 받아 Program으로 모델링 하는 메소드가 필요하다. | |
func setData(paper: T) throws -> Void | |
} |
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
extension String { | |
var isBlank: Bool { | |
return self.trimmingCharacters(in: .whitespaces).isEmpty | |
} | |
func substring(_ r: Range<Int>?) -> String { | |
guard let r = r else { return self } | |
let fromIndex = self.index(self.startIndex, offsetBy: r.lowerBound) | |
let toIndex = self.index(self.startIndex, offsetBy: r.upperBound) | |
let indexRange = Range<String.Index>(uncheckedBounds: (lower: fromIndex, upper: toIndex)) | |
return String(self[indexRange]) |
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
// | |
// WeakMap.swift | |
// dotNetTree | |
// | |
// Created by SeungChul Kang on 2018. 5. 1.. | |
// Copyright © 2018년 motel. All rights reserved. | |
// | |
import Foundation |
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
func parse(qs: String) -> [String: Any]? { | |
guard let regex = try? NSRegularExpression.init( | |
pattern: "(?:[^\\[\\]]+)", | |
options: NSRegularExpression.Options(rawValue: 0) | |
) else { | |
return nil | |
} | |
return qs |