<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>ku-ma-me</author_name>
  <author_url>https://blog.hatena.ne.jp/ku-ma-me/</author_url>
  <blog_title>まめめも</blog_title>
  <blog_url>https://mametter.hatenablog.com/</blog_url>
  <categories>
    <anon>Ruby</anon>
  </categories>
  <description>grep の -C オプションみたいなのって、意外に実装が難しいなと思いました。そこで考えた問題。 リストの中の条件を満たす要素の前後 n 個以外を省略する関数を書きなさい。例えば、 A B C D E F G H Iのリストに対して、E だけが条件を満たして、n = 2 であれば ..2.. C D E F G ..2..を出力する感じ。細かい仕様は勝手に決めてください。 Ruby 1.9 の新機能をふんだんに使った富豪的な解答。 def snip(a, n) a.dup.tap do |a| t = (0...a.size).to_a &amp; a.map.with_index {|x, i| …</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fmametter.hatenablog.com%2Fentry%2F20090227%2Fp1&quot; title=&quot; snip 関数 - まめめも&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>2009-02-27 00:00:00</published>
  <title> snip 関数</title>
  <type>rich</type>
  <url>https://mametter.hatenablog.com/entry/20090227/p1</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
