<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged statistics</title>
<link>https://ask.clojure.org/index.php/tag/statistics</link>
<description></description>
<item>
<title>Creating a &quot;sequence&quot; of numbers.</title>
<link>https://ask.clojure.org/index.php/10494/creating-a-sequence-of-numbers</link>
<description>&lt;p&gt;Hello Clojurians, I have a question on best practice for populating an array with a sequence of numbers.&lt;/p&gt;
&lt;p&gt;This is not a seq structure. I'm referring to a &lt;em&gt;mathematical sequence&lt;/em&gt;, e.g., 1, 2, 3, 4, 5, 6, 7, ..., n&lt;/p&gt;
&lt;p&gt;My background is in statistical programming, so generating lists of numbers is suprisingly common, and useful!&lt;/p&gt;
&lt;p&gt;In the R language, to produce an array of numbers you would do:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;seq(1, 10) =&amp;gt; [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or shorthand:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1:10 =&amp;gt; [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Either of these are considered idiomatic as they are readable and fast.&lt;/p&gt;
&lt;p&gt;Assigning the array to a variable would then be:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nums = seq(1, 10)
nums =&amp;gt; [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;What is the Clojure way of doing this?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Unfortunately I am having trouble searching the web for a solution as, inevitably, any search including &quot;sequence&quot; brings one to &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojuredocs.org/clojure.core/seq&quot;&gt;https://clojuredocs.org/clojure.core/seq&lt;/a&gt;.&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10494/creating-a-sequence-of-numbers</guid>
<pubDate>Mon, 19 Apr 2021 18:33:52 +0000</pubDate>
</item>
</channel>
</rss>