or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing
xxxxxxxxxx
Take & Skip
Take 與 Skip 是非常相似的 , 更精確的說法是他們在使用層面是互補的存在. Take 可以從原始資料集合中取出滿足使用者設定的條件或是個數的資料以取出連續的目標子集合. Skip 可以透過忽略使用者設定的條件或是個數的資料以取出連續的目標子集合. 也就是說將 Take 與 Skip 兩者取得的資料合併後 , 剛好為原本的資料集合(無重複). 故 Take 與 Skip 被稱為是 Partitioning Operators. 我自己看待這兩個方法 , 是想成使用某個茅點將資料集合切成兩個部分 , 然後一個部分使用 Take 取得 , 而另一個部分使用 Skip 取得.
Take 與 Skip 都各有三個方法可以使用.
Take
Take 可以取出使用者指定數量的連續項目的子集合. 其數量是從資料集合開頭開始算起. 若是使用者指定的數量超過資料集合數量 , 其會將整個資料集合回傳. 不會有例外發生
使用時機
槓 , 我從來沒用過呀.
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Take 的用法
取出前三個英文字母並印出
輸出結果
A
B
C
簡單實作自己的 Take
TakeWhile
TakeWhile 會從資料集合開頭逐一檢查資料成員是否滿足條件 , 一旦遇到不滿足條件的資料成員會中止搜尋 , 即使仍有符合條件的資料成員. 其與 Where 的差別在於 Where 會走訪所有的資料集合並將所有滿足條件的資料成員回傳.
使用時機
TakeWhile 的用法
輸出結果
ABCDE
FIJ
KLMN
輸出結果
ABCDE
FIJ
簡單實作自己的 TakeWhile
TakeLast
.NET Core 2.0 後 , 才提供的 LINQ 方法 TakeLast(). TakeLast 在順序上與 Take 相反. TakeLast 可以取出使用者指定數量的連續項目的子集合. 其數量是從資料集合尾部開始算起. 若是使用者指定的數量超過資料集合數量 , 其會將整個資料集合回傳. 不會有例外發生
使用時機
TakeLast 的用法
輸出結果
F
G
偷懶不想寫
簡單實作自己的 TakeLast
Skip
略過指定數量的集合元素 , 取其剩下的集合元素作為回傳結果. 指定數量的計算是從集合的第一個元素開始算起. 若指定數量大於集合元素則不會回傳任何元素 , 且不會跳出例外.
使用時機
對集合的運算操作 , 希望略過某幾個元素.
使用數量作為基準來進行集合分割動作
Skip 的用法
輸出結果
G
偷懶不想寫
簡單實作自己的 Skip
SkipWhile
SkipWhile 會從資料集合開頭逐一檢查資料成員是否滿足條件 , 滿足條件的資料成員會略過繼續走訪 , 直到遇到遇到第一個條件不滿足條件的項目 , 然後將剩餘的項目回傳(包含第一個條件不滿足的項目) .
使用時機
SkipWhile 的用法
輸出結果
F
G
偷懶不想寫
輸出結果
G
偷懶不想寫
簡單實作自己的 SkipWhile
SkipLast
.NET Core 2.0 後 , 才提供的 LINQ 方法 SkipLast(). SkipLast 在順序上與 SkipLast 相反. 由集合的最後一個元素往前記數,再到達指定的數量之前的元素都忽略不算在結果集合中. 若是使用者指定的數量超過資料集合數量則不會回傳任何元素 , 且不會跳出例外.
使用時機
SkipLast 的用法
輸出結果
A
B
C
簡單實作自己的 SkipLast
Summary
Thank you!
You can find me on
若有謬誤 , 煩請告知 , 新手發帖請多包涵
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →