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
//: Playground - noun: a place where people can play | |
//: ## 1 : 클래스의 프로퍼티 정의방법 | |
class Foo { | |
/// 일반적인 stored property | |
var a: Int = 4 | |
/// stored property + observer methods | |
var b: Int = 10 { | |
willSet { |
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
import Foundation | |
// MARK: Employee | |
class Employee: NSObject | |
{ | |
@objc dynamic var salary:Int | |
var name: String | |
init(name:String, salary:Int) { | |
self.name = name |
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
#import <Foundation/Foundation.h> | |
static void* theContext = &theContext; | |
/// KVC/KVO 호환 클래스. | |
@interface Foo: NSObject | |
@property (copy, nonatomic) NSString* moo; | |
-(void)doubleBar; | |
@end |
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
from urllib.request import urlopen | |
from subprocess import check_call | |
from queue import Queue | |
from threading import Thread, Lock | |
from tkinter import Tk | |
import re | |
import time | |
app = Tk() | |
app.withdraw() |
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
import socket | |
def client(): | |
host, port = '127.0.0.1', 4000 | |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | |
s.connect((host, port)) | |
print(s.recv(4096).decode()) | |
print(s.recv(4096).decode()) | |
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
pen n = (flip div 2) $ n * (n * 3 - 1) | |
main = getLine >> getContents >>= putStrLn . unlines . map (show . pen .read) . lines |
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
-- 구분구적법으로 곡선아래의 넓이와 회전체의 부피를 구하라. | |
{- 입력은 세 라인으로 | |
- 첫 줄은 다항식의 각 계수 | |
- 둘째줄은 다항식의 각 차수 | |
- 셋째줄은 구간의 시작값과 끝값 | |
- | |
- | |
- 구분 구적법에서 다항식 곡선의 넓이는 다음과 같이 계산한다. | |
- 시작값과 끝값사이에서 gap 만큼 조금씩 움직인다. | |
- x0 = leftBound + (gap_count * gap_size) |
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
# handle paste event | |
# paste image file to body | |
add-image = (img-file) !-> | |
an-image = document.create-element \img | |
reader = new FileReader! | |
# handle paste event | |
# paste image file to body | |
add-image = (img-file) !-> | |
# img-file :: File | |
# -- FileReader를 써서 읽어들여서 사용한다. |
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
#!/usr/bin/swift | |
import Foundation | |
let masks: [String] = ["02356789", "045689", "01234789", | |
"2345689", "0268", "013456789", "0235689"] | |
let digits = "1234567890" | |
let s = 3 |
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
def present(s, digits): | |
masks = ('02356789', '045689', '01234789', '2345689', '0268', '013456789', '0235689') | |
result = [] | |
h = lambda x: ' '.join(' ' + ('-' if d in masks[x] else ' ') * s + ' '\ | |
for d in digits) | |
v = lambda x: ' '.join(('|' if d in masks[x] else ' ') + ' ' * s +\ | |
('|' if d in masks[x+1] else ' ') for d in digits) | |
result.append(h(0)) | |
result += [v(1)] * s | |
result.append(h(3)) |