Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4323864
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:03:25+00:00 2026-05-21T09:03:25+00:00

I am using Clojure data structures all over the place but I am not

  • 0

I am using Clojure data structures all over the place but I am not using any lazy evaluation. Is there a performance penalty for using lazy structures everywhere?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:03:26+00:00Added an answer on May 21, 2026 at 9:03 am

    From the source code:

    clojure.lang.Cons (strict list element, clojure.lang.PersistentList is very similar), https://github.com/clojure/clojure/blob/1.2.0/src/jvm/clojure/lang/Cons.java#L34

    public Object first(){
        return _first;
    }
    

    clojure.lang.LazySeq (lazy sequence element), https://github.com/clojure/clojure/blob/1.2.0/src/jvm/clojure/lang/LazySeq.java#L77

    public Object first(){
        seq();
        if(s == null)
            return null;
        return s.first();
    }
    

    where

    final synchronized Object sval(){
        if(fn != null)
            {
            try
                {
                sv = fn.invoke();
                fn = null;
                }
            catch(Exception e)
                {
                throw new RuntimeException(e);
                }
            }
        if(sv != null)
            return sv;
        return s;
    }
    
    final synchronized public ISeq seq(){
        sval();
        if(sv != null)
            {
            Object ls = sv;
            sv = null;
            while(ls instanceof LazySeq)
                {
                ls = ((LazySeq)ls).sval();
                }
            s = RT.seq(ls);
            }
        return s;
    }
    

    So you’re definitely paying a price. It depends very much on each particular use case how much that price affects you and whether it’s offset by the memory savings and lack of wasted computation that lazy evaluation buys you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm happily using swank-clojure, installed via elpa. But I'd like to do some work
I'm using Maven in the context of another build-tool (leiningen for Clojure, but this
I am developing a complex data structure in Clojure with multiple sub-structures. I know
I want to automate filling in data on a website using clojure. For this
I am using this jquery ui autocomplete but i need to grab the data
I am trying to get meta-data of all built-in Clojure functions. In previous question
Using clojure I have a very large amount of data in a sequence and
I naively implemented the trie from Okasaki's book Purely Functional Data Structures in Clojure.
I am building some software using Clojure as a backend, and I'd like to
I'm calling the twitter4j library using Clojure like so: (def twitter (. (TwitterFactory.) getInstance))

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.