Skip to content

Instantly share code, notes, and snippets.

package main
import (
"bufio"
"errors"
"fmt"
"log"
"net/http"
"net/url"
"os"
// 以下サイトの4.1.2RELEASEで動きます。
// http://online.swiftplayground.run/
import Foundation
enum ViewMode: Equatable {
case normal
case createPosition(CGPoint)
case editMode
var isCreatePosition: Bool {
@tikidunpon
tikidunpon / golang.md
Last active February 13, 2018 13:42
go(golang)勉強会 #1

最近のシステム開発の傾向

  • コンピュータは速くなったが、ソフトウェア開発は速くなっていない
  • 依存性の管理はソフトウェア開発の多くを占める、しかしC言語のヘッダーでは高速に依存性を分析しづらい
  • JavaやC++のような扱いにくい型システムをもつシステムより、PythonやJavaScriptなど動的片付け言語が使われている
  • ガーベジコレクションや並列計算などの基本的なコンセプトのいくつかは一般的な言語で上手くサポートされていません
  • マルチコアコンピュータの登場により、心配と混乱が生じた

上記を受けてGoが解決を目指すこと

@tikidunpon
tikidunpon / Main.kt
Last active January 26, 2018 09:45
12章Null安全
fun main(args: Array<String>){
// Null安全
/**
* p171
* Javaにおけるnull
*/
// Javaでは参照をデリファレンスした時にnullだとNPE(NullPointerException)が起きる
// 05. n-gram
// 与えられたシーケンス(文字列やリストなど)からn-gramを作る関数を作成せよ.この関数を用い,"I am an NLPer"という文から単語bi-gram,文字bi-gramを得よ.
// 単語bi-gram
func q5_1(input: String, n: Int) -> [String] {
return wordNgram(input: input, n: n)
}
// 文字bi-gram
func q5_2(input: String, n: Int) -> [String] {
return charNgram(input: input, n: n)
@tikidunpon
tikidunpon / ReadKotlin7-8.kt
Created September 13, 2017 00:26
#read_kotlin Kotlinスタートブック読書勉強会 #5 第7,8章 クラスとそのメンバ〜(参考資料)
/**
* Created by koichitanaka on 2017/06/11.
*/
fun <T> println(message: T) {
print(Thread.currentThread().stackTrace[2].lineNumber.toString() + "行目 ")
print(message)
print("\n")
}
@tikidunpon
tikidunpon / Sample.kt
Created September 7, 2017 03:48
Kotlinスタートブック読書勉強会 #4 第6章 第一級オブジェクトとしての関数 (参考資料)
/**
* Created by koichitanaka on 2017/06/11.
*/
fun <T> println(message: T) {
print(Thread.currentThread().stackTrace[2].lineNumber.toString() + "行目 ")
print(message)
print("\n")
}
@tikidunpon
tikidunpon / CodePiece.kt
Created August 30, 2017 11:53
雑だけどlocal functionでprintln定義してlinenumberだすやつ #CodePiece #read_kotlin
fun main(args: Array<String>) {
fun <T> println(message: T) {
print(Thread.currentThread().stackTrace[2].lineNumber.toString() + "行目 ")
print(message)
print("\n")
}
println("hi")
}
@tikidunpon
tikidunpon / CodePiece.swift
Created April 10, 2017 12:08
nestした!は警告になるのね #read_swift #CodePiece
// Implicitly unwrapped optionals are only allowed at top level and as function resultsの警告がでる。
func a() -> (Int!, Int!) {
return (0,0)
}
@tikidunpon
tikidunpon / CodePiece.swift
Created March 14, 2017 14:43
ArrayがEquatableに準拠してないね、という話の流れから生まれたArrayの比較が可能な関数です。 ありがとうございます。 @es_kumagai #read_swift #CodePiece
/// ArrayがEquatableに準拠してないね、という話の流れから生まれたArrayの比較が可能な関数
func isEqual<T: Equatable>(_ x: Array<T>, _ y: Array<T>) -> Bool {
guard x.count == y.count else {
return false
}
return zip(x,y).reduce(true) { result, elements in
result && (elements.0 == elements.1)
}
}