# Force realization

**URL:** https://clojureverse.org/t/force-realization/11473
**Category:** Beginners
**Created:** [June 30, 2025, 1:40pm UTC](https://clojureverse.org/t/force-realization/11473 "2025-06-30T13:40:25Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![TIMT](https://clojureverse.org/user_avatar/clojureverse.org/timt/32/5835_2.png) [@TIMT](https://clojureverse.org/u/TIMT)
#### Post date: [June 30, 2025, 1:40pm UTC](https://clojureverse.org/t/force-realization/11473/1 "2025-06-30T13:40:25Z")

</div>

Hey,

I have coded quite a lot with Clojure already but I can’t get forced realization of a lazy seq to work. I already do this:

blocks (doall (into (group-subroutine-decs subroutine-dec-code)))

Sometimes, into forces the realization and I can easily debug my code. Sometimes doall does the trick (as the ClojureDocs say). In this case, nothing works. I can’t really debug the code because the value simply isn’t realised (IntelliJ).

Is there any trick I can use? I’d appreciate some help here

---

<div class="post-metadata">

### Author: ![p-himik](https://clojureverse.org/user_avatar/clojureverse.org/p-himik/32/4137_2.png) [@p-himik](https://clojureverse.org/u/p-himik)
#### Post date: [June 30, 2025, 1:48pm UTC](https://clojureverse.org/t/force-realization/11473/2 "2025-06-30T13:48:44Z")

</div>

Both of them realize the seq, `into []` also changes the type to a vector.

> In this case, nothing works. I can’t really debug the code because the value simply isn’t realised (IntelliJ).

What are the actual symptoms? What makes you think that whatever you’re seeing is due to collection realization and not something else?

---

<div class="post-metadata">

### Author: ![TIMT](https://clojureverse.org/user_avatar/clojureverse.org/timt/32/5835_2.png) [@TIMT](https://clojureverse.org/u/TIMT)
#### Post date: [June 30, 2025, 2:10pm UTC](https://clojureverse.org/t/force-realization/11473/3 "2025-06-30T14:10:59Z")

</div>

Well, I can’t really debug the code because I cannot see the value because it is not realised yet…

---

<div class="post-metadata">

### Author: ![p-himik](https://clojureverse.org/user_avatar/clojureverse.org/p-himik/32/4137_2.png) [@p-himik](https://clojureverse.org/u/p-himik)
#### Post date: [June 30, 2025, 3:19pm UTC](https://clojureverse.org/t/force-realization/11473/4 "2025-06-30T15:19:54Z")

</div>

You just repeated the OP without any details.

What exactly do you see? Can you share a screenshot?  
What makes you think that values aren’t realized?  
Can you create a small reproducible example?

---

<div class="post-metadata">

### Author: ![p-himik](https://clojureverse.org/user_avatar/clojureverse.org/p-himik/32/4137_2.png) [@p-himik](https://clojureverse.org/u/p-himik)
#### Post date: [June 30, 2025, 3:32pm UTC](https://clojureverse.org/t/force-realization/11473/5 "2025-06-30T15:32:51Z")

</div>

Here’s what I see, everything works as expected on my end. The only thing I don’t like here is that the `Explore Elements` link immediately realizes the lazy seq without prompting, but not a big deal.

`not-realized` cannot be expanded at all without changing the default viewer via RMB → View as.  
`realized` can be fully expanded and all the items are there, same for `as-vector`.

(Don’t pay any attention to that `:gap` - it’s a common issue when debugging Clojure where a breakpoint ends up being triggered earlier than where it was put, for some reason.)

 ![image](https://v2.clojureverse.org/uploads/default/original/2X/c/cf83cdaa6c4effe0048403af85d07b8e81f1bdb6.png)

---

<div class="post-metadata">

### Author: ![TIMT](https://clojureverse.org/user_avatar/clojureverse.org/timt/32/5835_2.png) [@TIMT](https://clojureverse.org/u/TIMT)
#### Post date: [July 4, 2025, 1:44pm UTC](https://clojureverse.org/t/force-realization/11473/6 "2025-07-04T13:44:46Z")

</div>

Hm, interesting. I did manage to enforce the realisation with this method, but I’ll always have to add it to any seq that might be lazy:

```auto
(defn pr2
  "Print + Return"
  [x]
  (prn x)
  x)

```

I currently try to write my result into a file, but the output file looks like this:

clojure.lang.LazySeq@a9ff4363()clojure.lang.LazySeq@30f30684()clojure.lang.LazySeq@8ecc864b()clojure.lang.LazySeq@d22be15d()clojure.lang.LazySeq@8ecc864b()clojure.lang.LazySeq@8ecc864b()clojure.lang.LazySeq@749aa280()clojure.lang.LazySeq@7771210d()clojure.lang.LazySeq@7bf6fda3()clojure.lang.LazySeq@abdb17a0()

The top level caller does this:

```auto
(defn compile-jack
  [filepath]
  (let [tokens (tokenize filepath)
        compiled (doall (compile-class tokens))]
    (result-vm-to-file filepath compiled)))

```

So neither the doall, nor the spit in result-vm-to-file seem to realize the result. I feel like I misunderstand something about doall pretty badly.

---

<div class="post-metadata">

### Author: ![seancorfield](https://clojureverse.org/user_avatar/clojureverse.org/seancorfield/32/195_2.png) [@seancorfield](https://clojureverse.org/u/seancorfield)
#### Post date: [July 4, 2025, 9:11pm UTC](https://clojureverse.org/t/force-realization/11473/7 "2025-07-04T21:11:05Z")

</div>

You are misunderstanding what you are seeing:

> [@TIMT](#):
>
> clojure.lang.LazySeq@a9ff4363

This is how a general Java object prints in Clojure, unless there is specific machinery to print it in a different format.

`doall` realizes a lazy sequence _but it is still a `LazySeq` object_ so that is how it is going to print by default.

If you want to print the _elements_ of a realized lazy sequence, you’ll need to either do so explicitly or “pour” it into a vector.

You don’t show what `compile-class` does but if you do not need a lazy sequence here, don’t use one: produce a vector instead.

Does that help?

---

<div class="post-metadata">

### Author: ![system](https://clojureverse.org/uploads/default/original/2X/5/51079bf9e4b7d9466242c06cf1e43b9f8bd6da14.png) [@system](https://clojureverse.org/u/system)
#### Post date: [January 3, 2026, 9:11am UTC](https://clojureverse.org/t/force-realization/11473/8 "2026-01-03T09:11:30Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
