Giter Club home page Giter Club logo

Comments (6)

ramonpin avatar ramonpin commented on May 26, 2024

Strangely when I change the filter-empty-dirs function by adding a println at the start of its second header it works well with both babashka versions:

(defn filter-empty-dirs
  ([entries]
   (let [groups (group-by #(dir? %) entries)
         dirs (map #(.path %) (groups true))
         files (map #(.path %) (groups false))]
     (filter-empty-dirs files dirs)))

  ([files dirs]
   (println (count files) (count dirs))  # This line makes it work
   (if (empty? files)
     dirs
     (let [[current-file & rest-files] files]
       (->> dirs
            (remove (path-components current-file))
            (recur rest-files))))))

from babashka.

borkdude avatar borkdude commented on May 26, 2024

I am repro-ing with docker with 1.3.185 and it also gives an SO:

docker run --rm -v $(pwd):/tmp babashka/babashka:1.3.185  bash -c 'cd /tmp; bb files.clj'

You can fix this by making remove strict before doing the recur:

(defn filter-empty-dirs
  ([entries]
   (let [groups (group-by #(dir? %) entries)
         dirs (map #(.path %) (groups true))
         files (map #(.path %) (groups false))]
     (filter-empty-dirs files dirs)))

  ([files dirs]
   (if (empty? files)
     dirs
     (let [[current-file & rest-files] files]
       (->> dirs
            (remove (path-components current-file))
            vec
            (recur rest-files))))))

from babashka.

ramonpin avatar ramonpin commented on May 26, 2024

Thnks!!!!

from babashka.

ramonpin avatar ramonpin commented on May 26, 2024

Strangely it does not fail for me when I use 1.3.185 docker image as you do. But it does when I use 1.3.186.

https://asciinema.org/a/1CqV7e3aLnpLMqeSvwIbccpmt

from babashka.

borkdude avatar borkdude commented on May 26, 2024

It could be that the stack size is slightly different in your case, but lazy expression don't mix well with deeply recursive code and is known to cause such problems sooner or later.

from babashka.

ramonpin avatar ramonpin commented on May 26, 2024

Great!!! Thank you for your patience.

from babashka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.