<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged stackoverflow</title>
<link>https://ask.clojure.org/index.php/tag/stackoverflow</link>
<description></description>
<item>
<title>clojure.java.data/from-java throws stack overflow</title>
<link>https://ask.clojure.org/index.php/14379/clojure-java-data-from-java-throws-stack-overflow</link>
<description>&lt;p&gt;I use the following function to get scrollpoints from a  client io.qdrant.client.QdrantClient&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def client ...) =&amp;gt; io.qdrant.client.QdrantClient

(defn make-scroll-points [collection-name k v]
  (builder/to-java Points$ScrollPoints
                   Points$ScrollPoints$Builder
                   (Points$ScrollPoints/newBuilder)
                   {:collectionName collection-name
                    :filter (builder/to-java Points$Filter
                                             Points$Filter$Builder
                                             (Points$Filter/newBuilder)
                                             {:addMust (ConditionFactory/matchKeyword (name k) (str v))}
                                             {})
                    :limit 1
                    :withPayload (WithPayloadSelectorFactory/enable true)}
                   {}))

(def scroll-points (qdrant/make-scroll-points  &amp;lt;collection-name&amp;gt; :user &quot;user-1&quot;))

(def scrolled (.get (.scrollAsync client scroll-points)))
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;(bean scrolled)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;works,  but when i do&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(clojure.java.data/from-java scrolled)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I get a stackoverflow error&lt;/p&gt;
</description>
<category>java.data</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14379/clojure-java-data-from-java-throws-stack-overflow</guid>
<pubDate>Mon, 10 Feb 2025 10:39:57 +0000</pubDate>
</item>
<item>
<title>Stack overflow with lazy-seq</title>
<link>https://ask.clojure.org/index.php/13937/stack-overflow-with-lazy-seq</link>
<description>&lt;p&gt;I'm learning Clojure by doing problems from &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/PEZ/rich4clojure&quot;&gt;rich4clojure&lt;/a&gt; repo. &lt;a rel=&quot;nofollow&quot; href=&quot;https://gist.github.com/PEZ/9dcf23444c51883c4318d69efcd5e9f7&quot;&gt;Problem 147&lt;/a&gt; asks one to create a function which returns a lazy sequence of rows following rules of Pascal triangle given initial row. For example, for [3 1 2], the next row is [3 4 3 2]. Here's my solution:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn pascal
      ([row] (lazy-seq (cons row (__ row :next))))
      ([row _]
       (lazy-seq
        (let [next-row (map #(apply +' %) (partition 2 1 (concat '(0) row '(0))))]
          (cons next-row (pascal next-row :next)))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I decided to test it and compare it with solutions others came up with. For example, one user wrote:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn pascal [coll]
(lazy-seq
  (cons coll
        (pascal (let [middle (map #(apply +' %) (partition 2 1 coll))]
                       (concat [(first coll)] middle [(last coll)]))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I time both solutions by evaluating:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;time (nth (nth (pascal [1]) 400) 50))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and it turns out that mine is faster (which is sort of expected because the other user relies on &lt;em&gt;last&lt;/em&gt; which is O(n)). However, when I try to calculate 1000th row, I get stack overflow error only in case of my function. I'm struggling to see why this happens because I shouldn't be increasing the stack size. What am I missing?&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13937/stack-overflow-with-lazy-seq</guid>
<pubDate>Sun, 02 Jun 2024 19:14:33 +0000</pubDate>
</item>
</channel>
</rss>