<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>Windymelt</author_name>
  <author_url>https://blog.hatena.ne.jp/Windymelt/</author_url>
  <blog_title>Lambdaカクテル</blog_title>
  <blog_url>https://blog.3qe.us/</blog_url>
  <categories>
    <anon>技術</anon>
    <anon>scala</anon>
  </categories>
  <description>こういうSeqがあるとする。 val lis = Seq(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) これの先頭要素と、最後の要素、そしてどちらでもない中間の要素を取り出したい。 素朴にやると、headとlastとを使って、slice(1, lis.size)を使うことになるが、これをパターンマッチでやりたい。 実はScalaではルートのパッケージオブジェクトに+:と:+というextractorが定義されているので、以下のように書けるのだ: lis match { case head +: mid :+ last =&gt; s&quot;head is $head, mid contain…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.3qe.us%2Fentry%2F2023%2F05%2F06%2F024015&quot; title=&quot;ScalaでSeqの先頭と中間と最後をパターンマッチで取り出すには+:と:+を使うと良い - Lambdaカクテル&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2023-05-06 02:40:15</published>
  <title>ScalaでSeqの先頭と中間と最後をパターンマッチで取り出すには+:と:+を使うと良い</title>
  <type>rich</type>
  <url>https://blog.3qe.us/entry/2023/05/06/024015</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
