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 3273826
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:58:22+00:00 2026-05-17T18:58:22+00:00

I am creating trees of s-expressions for a genetic programming problem, and need to

  • 0

I am creating trees of s-expressions for a genetic programming problem, and need to alter parts of the trees during the evolution process. I came across the Clojure zipper function that seems like it should be perfect, but for the life of me I can’t figure out how to use it.

For example, say I create a zipper with

(def zipped (zip/seq-zip `(+ (- 1 2) 3)))

I understand this to represent a tree with + at the root, one that looks like this:

   +
 -   3
1 2

My zipper, though, doesn’t agree with this: If I ask for the first node with (-> zipped zip/down zip/node) it gives me + (which is correct) but it (-> zipped zip/down zip/down) doesn’t take me to -, instead it returns nil. Indeed, (-> zipped zip/down zip/rights) gives the rest of the tree as siblings to the right of the root, which suggests to me that I don’t have a tree at all:

user> (-> zipped zip/down zip/rights)
((clojure.core/- 1 2) 3)

I’m pretty sure I’m representing my trees correctly because when I execute them I get the right answer. Does zipper expect a different layout?

  • 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-17T18:58:23+00:00Added an answer on May 17, 2026 at 6:58 pm

    The problem is that there are two different ideas of tree going on here. Your tree is a graph of how the values percolate through the evaluation, but LISP is thinking about lists of lists, and using prefix notation:

    ‘(+ (- 1 2) 3) is also (list + (list – 1 2) 3), which is actually this tree:

    +  .     3
       - 1 2
    

    (-> zipped down node) gives you the first element, +, an atom.
    (-> zipped down down) thus gives you nil because the first element, +, is an atom.
    (-> zipped down right down node) gives you the minus sign you want because that’s the first element of the second element of the expression.

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

Sidebar

Related Questions

When I was looking to the System.Linq.Expression capabilities (creating expression trees in code, compiling
I am creating Linq expression trees from F# that operates on a custom datatype
Whilst creating an inline ANTLR Tree Grammar interpreter I have come across an issue
I need some combined functionality regarding drag'n'drop between two trees in ExtJS . The
I need to avoid creating double branches in an xml tree when parsing a
I needed some help with creating custom trees given an arithmetic expression. Say, for
I'm creating a file for internal storage, and I'm running into a problem when
Creating Traversals for Binary Search Tree with Recursion. void inOrder(void (*inOrderPtr)(T&)) { if(this->left !=
Creating a patch is very easy in SubVersion, With Tortoise, you right-click and select
Creating hashes of hashes in Ruby allows for convenient two (or more) dimensional lookups.

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.