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

  • SEARCH
  • Home
  • 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 7596549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:56:35+00:00 2026-05-30T21:56:35+00:00

This blog post ( http://williamedwardscoder.tumblr.com/post/18319031919/programming-language-readability ) contains implementation of autocompletion in Haskell and Python

  • 0

This blog post (http://williamedwardscoder.tumblr.com/post/18319031919/programming-language-readability) contains implementation of autocompletion in Haskell and Python to compare the readability of the programming languages.

Curious to find out how to implement the same in Clojure. Will Clojure codes be more readable due to its greater abstraction ability?

  • 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-30T21:56:36+00:00Added an answer on May 30, 2026 at 9:56 pm

    A minimalist implementation:

    (ns trie.example)
    
    (defn trie-add [trie & words]
      (reduce
       (fn [trie word]
         (assoc-in trie (concat word [::val]) word))
       trie
       words))
    
    (defn trie-matches [trie prefix]
      (letfn [(search [node]
                (mapcat (fn [[k v]]
                          (if (= ::val k) [v] (search v)))
                        node))]
        (search (get-in trie prefix))))
    

    Example usage:

    ;; Create trie
    (def trie (trie-add {} "foo" "ba" "bar" "baz" "qux" "quux"))
    
    ;; trie looks like this:
    {\q
     {\u
      {\u {\x {:trie.example/val "quux"}},
       \x {:trie.example/val "qux"}}},
     \b
     {\a
      {\z {:trie.example/val "baz"},
       \r {:trie.example/val "bar"},
       :trie.example/val "ba"}},
     \f {\o {\o {:trie.example/val "foo"}}}}
    
    ;; Autocomplete
    (trie-matches trie "ba")
    => ("baz" "bar" "ba")
    

    Things like sorting, storing non-word values, and compression are left as an exercise to the reader.

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

Sidebar

Related Questions

Just finished reading this blog post: http://www.skorks.com/2010/03/an-interview-question-that-prints-out-its-own-source-code-in-ruby/ In it, the author argues the case
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
In response to this blog post: http://www.simonecarletti.com/blog/2009/02/capistrano-uploads-folder/ I have three questions: Can anyone confirm
I like the pattern I saw in this blog post ( http://marekblotny.blogspot.com/2009/04/conventions-after-rewrite.html ), where
I'm trying to follow this blog post: http://blogs.msdn.com/b/carlosfigueira/archive/2011/04/19/wcf-extensibility-message-inspectors.aspx My aim is to somehow get
http://code.flickr.com/blog/page/4/ This blog post is from the devs at Flickr, and outlines their simplified
I'm following this blog post about setting up ELMAH with MVC: http://dotnetdarren.wordpress.com/2010/07/27/logging-on-mvc-part-1/ I've only
After reading this blog post: http://www.sitepoint.com/javascript-shared-web-workers-html5/ I don't get it. What's the difference between
See the bullets on this blog post: http://www.nielsbrinch.com/managing-expectation-management/ I have had to change to
I tried to consolidate everything I learned about normalization in this blog post http://geekyisawesome.blogspot.com/2011/03/database-normalization-1-2-3-nf.html

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.