開発環境
- OS X Mavericks - Apple(OS)
- Xcode 6.0 Beta
- Swift (プログラミング言語)
Practical Programming: An Introduction to Computer Science Using Python 3 (Pragmatic Programmers) (Paul Gries (著)、Jennifer Campbell (著)、Jason Montojo (著)、Lynn Beighley (編集)、Pragmatic Bookshelf)のChapter 8(Storing Collections of Data Using Array)、8.9(Exercises) 8.をSwiftで考えてみる。
8.9(Exercises) 8.
コード(Xcode)
main.swift
// // main.swift // mple8 // // Created by kamimura on 8/28/14. // Copyright (c) 2014 kamimura. All rights reserved. // import Foundation func isLonger<T1, T2>(a1:[T1], a2:[T2]) -> Bool { return a1.count > a2.count } func test<T1, T2>(a1:[T1], a2:[T2], b:Bool) { println(isLonger(a1, a2) == b) } test([1, 2, 3], [4, 5], true) test(["abcde"], ["ab", "cd", "ef"], false) test(["a", "b", "c"], [1, 2, 3], false)
入出力結果(Console Output)
true true true Program ended with exit code: 0
0 コメント:
コメントを投稿