Upgrade to Pro — share decks privately, control downloads, hide ads and more …

わいわいOperator

giginet
September 12, 2018

 わいわいOperator

giginet

September 12, 2018
Tweet

More Decks by giginet

Other Decks in Programming

Transcript

  1. import Foundation import Peafowl postfix operator ᤈ extension Int {

    postfix static func ᤈ(lhs: Int) -> Tile { return Tile(.character(lhs))! } } 1ᤈ
  2. /// isOperatorStartCodePoint - Return true if the specified code point

    is a /// valid start of an operator. static bool isOperatorStartCodePoint(uint32_t C) { // ASCII operator chars. static const char OpChars[] = "/=-+*%<>!&|^~.?"; if (C < 0x80) return memchr(OpChars, C, sizeof(OpChars) - 1) != 0; // Unicode math, symbol, arrow, dingbat, and line/box drawing chars. return (C >= 0x00A1 && C <= 0x00A7) || C == 0x00A9 || C == 0x00AB || C == 0x00AC || C == 0x00AE || C == 0x00B0 || C == 0x00B1 || C == 0x00B6 || C == 0x00BB || C == 0x00BF || C == 0x00D7 || C == 0x00F7 || C == 0x2016 || C == 0x2017 || (C >= 0x2020 && C <= 0x2027) || (C >= 0x2030 && C <= 0x203E) || (C >= 0x2041 && C <= 0x2053) || (C >= 0x2055 && C <= 0x205E) || (C >= 0x2190 && C <= 0x23FF) || (C >= 0x2500 && C <= 0x2775) || (C >= 0x2794 && C <= 0x2BFF) || (C >= 0x2E00 && C <= 0x2E7F) || (C >= 0x3001 && C <= 0x3003) || (C >= 0x3008 && C <= 0x3030); }
  3. ΦϚέ2 • ੃ṛΛ൑ఆ͢ΔCharacterSetͰ͢ import Foundation public let MahjongTileCharacterSet = {

    () -> CharacterSet in let start = Character("").unicodeScalars.first! let end = Character("").unicodeScalars.first! let range: ClosedRange<Unicode.Scalar> = start...end return CharacterSet(charactersIn: range) }()