Source

blade / docs / _build / html / xmap.html



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>blade.xmap &mdash; blade  documentation</title>
    
    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="_static/print.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <script type="text/javascript" src="_static/theme_extras.js"></script>
    <link rel="top" title="blade  documentation" href="index.html" />
    <link rel="next" title="blade.xmath" href="xmath.html" />
    <link rel="prev" title="blade.xfilter" href="xfilter.html" /> 
  </head>
  <body>
      <div class="header"><img class="rightlogo" src="_static/knife-smaller.png" alt="Logo"/><h1 class="heading"><a href="index.html">
          <span>blade  documentation</span></a></h1>
        <h2 class="heading"><span>blade.xmap</span></h2>
      </div>
      <div class="topnav">
      
        <p>
        «&#160;&#160;<a href="xfilter.html"><tt class="docutils literal docutils literal docutils literal"><span class="pre">blade.xfilter</span></tt></a>
        &#160;&#160;::&#160;&#160;
        <a class="uplink" href="index.html">Contents</a>
        &#160;&#160;::&#160;&#160;
        <a href="xmath.html"><tt class="docutils literal"><span class="pre">blade.xmath</span></tt></a>&#160;&#160;»
        </p>

      </div>
      <div class="content">
        
        
  <div class="section" id="module-blade.xmap">
<span id="blade-xmap"></span><h1><a class="reference internal" href="#module-blade.xmap" title="blade.xmap"><tt class="xref py py-class docutils literal"><span class="pre">blade.xmap</span></tt></a><a class="headerlink" href="#module-blade.xmap" title="Permalink to this headline"></a></h1>
<p><tt class="xref py py-class docutils literal"><span class="pre">blade</span></tt> mapping operations</p>
<dl class="function">
<dt id="blade.xmap.xargmap">
<tt class="descclassname">blade.xmap.</tt><tt class="descname">xargmap</tt><big>(</big><em>iterable</em>, <em>callable</em>, <em>merge=False</em>, <em>*args</em><big>)</big><a class="headerlink" href="#blade.xmap.xargmap" title="Permalink to this definition"></a></dt>
<dd><p>Feed each items in <cite>iterable</cite> to <cite>callable</cite> as <a class="reference external" href="http://docs.python.org/2.7/glossary.html#term-positional-argument" title="(in Python v2.7)"><em class="xref std std-term">positional argument</em></a>s.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>iterable</strong> &#8211; <a class="reference external" href="http://docs.python.org/2.7/glossary.html#term-iterable" title="(in Python v2.7)"><em class="xref std std-term">iterable</em></a></li>
<li><strong>callable</strong> &#8211; mapped <a class="reference external" href="http://docs.python.org/2.7/library/functions.html#callable" title="(in Python v2.7)"><tt class="xref py py-func docutils literal"><span class="pre">callable</span></tt></a></li>
<li><strong>merge</strong> (<a class="reference external" href="http://docs.python.org/2.7/library/functions.html#bool" title="(in Python v2.7)"><em>bool</em></a>) &#8211; merge global positional <tt class="xref py py-meth docutils literal"><span class="pre">params</span></tt> with positional
arguments derived from items in <cite>iterable</cite> when passed to <cite>callable</cite></li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">blade.xmap</span> <span class="kn">import</span> <span class="n">xargmap</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># default behavior</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">xargmap</span><span class="p">([(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">)],</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">*</span> <span class="n">y</span><span class="p">))</span>
<span class="go">[2, 6, 12]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># merge global positional arguments with iterable arguments</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">xargmap</span><span class="p">(</span>
<span class="gp">... </span>  <span class="p">[(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">)],</span>
<span class="gp">... </span>  <span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="n">x</span> <span class="o">*</span> <span class="n">y</span> <span class="o">*</span> <span class="n">z</span> <span class="o">*</span> <span class="n">a</span> <span class="o">*</span> <span class="n">b</span><span class="p">,</span>
<span class="gp">... </span>  <span class="bp">True</span><span class="p">,</span>
<span class="gp">... </span>  <span class="mi">7</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span>
<span class="gp">... </span> <span class="p">))</span>
<span class="go">[1008, 3024, 6048]</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="blade.xmap.xcopy">
<tt class="descclassname">blade.xmap.</tt><tt class="descname">xcopy</tt><big>(</big><em>iterable</em><big>)</big><a class="headerlink" href="#blade.xmap.xcopy" title="Permalink to this definition"></a></dt>
<dd><p>Duplicate each items in <cite>iterable</cite>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>iterable</strong> &#8211; <a class="reference external" href="http://docs.python.org/2.7/glossary.html#term-iterable" title="(in Python v2.7)"><em class="xref std std-term">iterable</em></a></td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">blade.xmap</span> <span class="kn">import</span> <span class="n">xcopy</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">xcopy</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]],</span> <span class="p">[</span><span class="mi">4</span><span class="p">,</span> <span class="p">[</span><span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">]]]))</span>
<span class="go">[[1, [2, 3]], [4, [5, 6]]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="blade.xmap.xinvoke">
<tt class="descclassname">blade.xmap.</tt><tt class="descname">xinvoke</tt><big>(</big><em>iterable</em>, <em>name</em>, <em>*args</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#blade.xmap.xinvoke" title="Permalink to this definition"></a></dt>
<dd><p>Feed global <a class="reference external" href="http://docs.python.org/2.7/glossary.html#term-positional-argument" title="(in Python v2.7)"><em class="xref std std-term">positional argument</em></a>s and <a class="reference external" href="http://docs.python.org/2.7/glossary.html#term-keyword-argument" title="(in Python v2.7)"><em class="xref std std-term">keyword argument</em></a>s to
each items in <cite>iterable</cite>&#8216;s <cite>name</cite> <a class="reference external" href="http://docs.python.org/2.7/glossary.html#term-method" title="(in Python v2.7)"><em class="xref std std-term">method</em></a>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The original thing is returned if the return value of <a class="reference external" href="http://docs.python.org/2.7/glossary.html#term-method" title="(in Python v2.7)"><em class="xref std std-term">method</em></a>
<cite>name</cite> is <a class="reference external" href="http://docs.python.org/2.7/library/constants.html#None" title="(in Python v2.7)"><tt class="xref py py-data docutils literal"><span class="pre">None</span></tt></a>.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>iterable</strong> &#8211; <a class="reference external" href="http://docs.python.org/2.7/glossary.html#term-iterable" title="(in Python v2.7)"><em class="xref std std-term">iterable</em></a></li>
<li><strong>name</strong> (<a class="reference external" href="http://docs.python.org/2.7/library/functions.html#str" title="(in Python v2.7)"><em>str</em></a>) &#8211; method name</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">blade.xmap</span> <span class="kn">import</span> <span class="n">xinvoke</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># invoke list.index()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">xinvoke</span><span class="p">([[</span><span class="mi">5</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">],</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">]],</span> <span class="s">&#39;index&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">[1, 2]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># invoke list.sort() but return sorted list instead of None</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">xinvoke</span><span class="p">([[</span><span class="mi">5</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">],</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">]],</span> <span class="s">&#39;sort&#39;</span><span class="p">))</span>
<span class="go">[[1, 5, 7], [1, 2, 3]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="blade.xmap.xkeyvalue">
<tt class="descclassname">blade.xmap.</tt><tt class="descname">xkeyvalue</tt><big>(</big><em>iterable</em>, <em>callable=None</em>, <em>keys=False</em>, <em>values=False</em><big>)</big><a class="headerlink" href="#blade.xmap.xkeyvalue" title="Permalink to this definition"></a></dt>
<dd><p>Run <cite>callable</cite> on incoming <a class="reference external" href="http://docs.python.org/2.7/glossary.html#term-mapping" title="(in Python v2.7)"><em class="xref std std-term">mapping</em></a> things.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>iterable</strong> &#8211; <a class="reference external" href="http://docs.python.org/2.7/glossary.html#term-iterable" title="(in Python v2.7)"><em class="xref std std-term">iterable</em></a></li>
<li><strong>callable</strong> &#8211; mapped <a class="reference external" href="http://docs.python.org/2.7/library/functions.html#callable" title="(in Python v2.7)"><tt class="xref py py-func docutils literal"><span class="pre">callable</span></tt></a></li>
<li><strong>keys</strong> (<a class="reference external" href="http://docs.python.org/2.7/library/functions.html#bool" title="(in Python v2.7)"><em>bool</em></a>) &#8211; collect mapping keys only</li>
<li><strong>values</strong> (<a class="reference external" href="http://docs.python.org/2.7/library/functions.html#bool" title="(in Python v2.7)"><em>bool</em></a>) &#8211; collect mapping values only</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">blade.xmap</span> <span class="kn">import</span> <span class="n">xkeyvalue</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># filter items</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">xkeyvalue</span><span class="p">(</span>
<span class="gp">... </span><span class="p">[</span><span class="nb">dict</span><span class="p">([(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">)]),</span> <span class="nb">dict</span><span class="p">([(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">)])],</span>
<span class="gp">... </span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">*</span> <span class="n">y</span><span class="p">))</span>
<span class="go">[2, 6, 12, 2, 6, 12]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># mapping keys only</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">xkeyvalue</span><span class="p">(</span>
<span class="gp">... </span><span class="p">[</span><span class="nb">dict</span><span class="p">([(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">)]),</span> <span class="nb">dict</span><span class="p">([(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">)])],</span>
<span class="gp">... </span><span class="n">keys</span><span class="o">=</span><span class="bp">True</span>
<span class="gp">... </span><span class="p">))</span>
<span class="go">[1, 2, 3, 1, 2, 3]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># mapping values only</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">xkeyvalue</span><span class="p">(</span>
<span class="gp">... </span><span class="p">[</span><span class="nb">dict</span><span class="p">([(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">)]),</span> <span class="nb">dict</span><span class="p">([(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">)])],</span>
<span class="gp">... </span><span class="n">values</span><span class="o">=</span><span class="bp">True</span>
<span class="gp">... </span><span class="p">))</span>
<span class="go">[2, 3, 4, 2, 3, 4]</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="blade.xmap.xkwargmap">
<tt class="descclassname">blade.xmap.</tt><tt class="descname">xkwargmap</tt><big>(</big><em>iterable</em>, <em>callable</em>, <em>merge=False</em>, <em>*args</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#blade.xmap.xkwargmap" title="Permalink to this definition"></a></dt>
<dd><p>Feed each items in <cite>iterable</cite> as a <a class="reference external" href="http://docs.python.org/2.7/library/functions.html#tuple" title="(in Python v2.7)"><tt class="xref py py-func docutils literal"><span class="pre">tuple</span></tt></a> of
<a class="reference external" href="http://docs.python.org/2.7/glossary.html#term-positional-argument" title="(in Python v2.7)"><em class="xref std std-term">positional argument</em></a>s and <a class="reference external" href="http://docs.python.org/2.7/glossary.html#term-keyword-argument" title="(in Python v2.7)"><em class="xref std std-term">keyword argument</em></a>s to <cite>callable</cite>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>iterable</strong> &#8211; <a class="reference external" href="http://docs.python.org/2.7/glossary.html#term-iterable" title="(in Python v2.7)"><em class="xref std std-term">iterable</em></a></li>
<li><strong>callable</strong> &#8211; mapped <a class="reference external" href="http://docs.python.org/2.7/library/functions.html#callable" title="(in Python v2.7)"><tt class="xref py py-func docutils literal"><span class="pre">callable</span></tt></a></li>
<li><strong>merge</strong> (<a class="reference external" href="http://docs.python.org/2.7/library/functions.html#bool" title="(in Python v2.7)"><em>bool</em></a>) &#8211; merge global positional or keyword <tt class="xref py py-meth docutils literal"><span class="pre">params</span></tt>
with positional and keyword arguments derived from items in <cite>iterable</cite>
into a single <a class="reference external" href="http://docs.python.org/2.7/library/functions.html#tuple" title="(in Python v2.7)"><tt class="xref py py-func docutils literal"><span class="pre">tuple</span></tt></a> of wildcard positional and keyword
arguments like <tt class="docutils literal"><span class="pre">(*iterable_args</span> <span class="pre">+</span> <span class="pre">global_args,</span> <span class="pre">**global_kwargs</span> <span class="pre">+</span>
<span class="pre">iterable_kwargs)</span></tt> when passed to <cite>callable</cite></li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">blade.xmap</span> <span class="kn">import</span> <span class="n">xkwargmap</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># default behavior</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">test</span> <span class="o">=</span> <span class="p">[((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">{</span><span class="s">&#39;a&#39;</span><span class="p">:</span> <span class="mi">2</span><span class="p">}),</span> <span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="p">{</span><span class="s">&#39;a&#39;</span><span class="p">:</span> <span class="mi">2</span><span class="p">}),</span> <span class="p">((</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">),</span> <span class="p">{</span><span class="s">&#39;a&#39;</span><span class="p">:</span> <span class="mi">2</span><span class="p">})]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">tester</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">):</span>
<span class="gp">... </span>   <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">*</span> <span class="nb">sum</span><span class="p">(</span><span class="n">kw</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">xkwargmap</span><span class="p">(</span><span class="n">test</span><span class="p">,</span> <span class="n">tester</span><span class="p">))</span>
<span class="go">[6, 10, 14]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># merging global and iterable derived positional and keyword args</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">xkwargmap</span><span class="p">(</span><span class="n">test</span><span class="p">,</span> <span class="n">tester</span><span class="p">,</span> <span class="bp">True</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">w</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">y</span><span class="o">=</span><span class="mi">13</span><span class="p">))</span>
<span class="go">[270, 330, 390]</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="blade.xmap.xrepeat">
<tt class="descclassname">blade.xmap.</tt><tt class="descname">xrepeat</tt><big>(</big><em>iterable</em>, <em>callable=None</em>, <em>n=None</em><big>)</big><a class="headerlink" href="#blade.xmap.xrepeat" title="Permalink to this definition"></a></dt>
<dd><p>Repeat items in <cite>iterable</cite> <cite>n</cite> times or invoke <cite>callable</cite> <cite>n</cite> times.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>iterable</strong> &#8211; <a class="reference external" href="http://docs.python.org/2.7/glossary.html#term-iterable" title="(in Python v2.7)"><em class="xref std std-term">iterable</em></a></li>
<li><strong>callable</strong> &#8211; <a class="reference external" href="http://docs.python.org/2.7/library/functions.html#callable" title="(in Python v2.7)"><tt class="xref py py-func docutils literal"><span class="pre">callable</span></tt></a> to repeatedly invoke</li>
<li><strong>n</strong> (<a class="reference external" href="http://docs.python.org/2.7/library/functions.html#int" title="(in Python v2.7)"><em>int</em></a>) &#8211; number of times to repeat</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">blade.xmap</span> <span class="kn">import</span> <span class="n">xrepeat</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># repeat iterable</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">xrepeat</span><span class="p">([</span><span class="mi">40</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">60</span><span class="p">],</span> <span class="n">n</span><span class="o">=</span><span class="mi">3</span><span class="p">))</span>
<span class="go">[(40, 50, 60), (40, 50, 60), (40, 50, 60)]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># with callable</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">xrepeat</span><span class="p">([</span><span class="mi">40</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">60</span><span class="p">],</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="nb">list</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="mi">3</span><span class="p">))</span>
<span class="go">[[40, 50, 60], [40, 50, 60], [40, 50, 60]]</span>
</pre></div>
</div>
</dd></dl>

</div>


      </div>
      <div class="bottomnav">
      
        <p>
        «&#160;&#160;<a href="xfilter.html"><tt class="docutils literal docutils literal docutils literal"><span class="pre">blade.xfilter</span></tt></a>
        &#160;&#160;::&#160;&#160;
        <a class="uplink" href="index.html">Contents</a>
        &#160;&#160;::&#160;&#160;
        <a href="xmath.html"><tt class="docutils literal"><span class="pre">blade.xmath</span></tt></a>&#160;&#160;»
        </p>

      </div>

    <div class="footer">
        &copy; Copyright 2012, L. C. Rees.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>