Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

解答例の折りたたみを実現 #64

Merged
merged 2 commits into from
Apr 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"gitbook-plugin-footnote-string-to-number": "0.0.2",
"gitbook-plugin-include-codeblock": "1.6.1",
"gitbook-plugin-japanese-support": "0.0.1",
"gitbook-plugin-regexplace":"1.0.6",
"kramed": "0.5.5",
"mocha": "2.4.5",
"npm-check-updates": "2.5.8",
Expand Down
11 changes: 10 additions & 1 deletion src/book.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
"include-codeblock",
"japanese-support",
"footnote-string-to-number",
"anchors"
"anchors",
"regexplace"
],
"pluginsConfig": {
"regexplace": {
"substitutes": [
{"pattern": "<!-- begin answer id=\"(.*)\" style=\"(.*)\" -->", "flags": "g", "substitute": "<div><button type=\"button\" onclick=\"document.getElementById('$1').style.display='block';\">解答例を表示する</button><button type=\"button\" onclick=\"document.getElementById('$1').style.display='none';\">解答例を隠す</button></div><div id=\"$1\" style=\"$2\">"},
{"pattern": "<!-- end answer -->", "flags": "g", "substitute": "</div>"}
]
}
},
"title": "Scala研修テキスト"
}
8 changes: 6 additions & 2 deletions src/collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ arr.length
def swapArray[T](arr: Array[T])(i: Int, j: Int): Unit = ???
```

となります。ヒント:`swapArray`の結果は次のようになっていなければいけません。また、`i`と`j`が配列の範囲外である場合は特に考慮しなくて良いです。解答例は[こちら](https://github.com/dwango/scala_text/blob/master/src/collection.md#練習問題)から。
となります。ヒント:`swapArray`の結果は次のようになっていなければいけません。また、`i`と`j`が配列の範囲外である場合は特に考慮しなくて良いです。

```tut:invisible
<!-- begin answer id="sectionex1" style="display:none" -->

```tut
def swapArray[T](arr: Array[T])(i: Int, j: Int): Unit = {
val tmp = arr(i)
arr(i) = arr(j)
Expand All @@ -92,6 +94,8 @@ swapArray(arr)(1, 3)
arr
```

<!-- end answer -->

### [Range](https://github.com/scala/scala/blob/v2.11.8/src/library/scala/collection/immutable/Range.scala)(★★)

`Range`は範囲を表すオブジェクトです。`Range`は直接名前を指定して生成するより、`to`メソッドと`until`メソッドを用いて呼びだすことが多いです。また、`toList`メソッドを用いて、その範囲の数値の列を後述する`List`に変換することができます。では、早速REPLで`Range`を使ってみましょう。
Expand Down