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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:03:16+00:00 2026-05-19T02:03:16+00:00

I have a method called visualize in my Clojure application which can supposedly render

  • 0

I have a method called “visualize” in my Clojure application which can supposedly render any part of my application. The problem I have is that some things in my application are Java classes and some are hashmaps, with fields internally marking the type of the map using the clojure :: idiom. I know I can use multimaps to dispatch on type or on some internal type, but how can I do it so that the same multimethod works on BOTH.

  • 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-19T02:03:16+00:00Added an answer on May 19, 2026 at 2:03 am

    Create a dispatch function that both looks for maps with a special marker type and for Java classes.

    (defn visualize-dispatch [foo]
      (if (map? foo) 
        (:type foo)
        (class foo)))
    
    (defmulti visualize visualize-dispatch)
    
    (defmethod visualize String [s] 
      (println "Got a string" s))
    
    (defmethod visualize :banana [b] 
      (println "Got a banana that is" (:val b)))
    

    Then you can call visualize with either one of your Java classes or a map like {:type :banana :val “something”}.

    user> (visualize "bikini")
    Got a string bikini
    user> (visualize {:type :banana :val "speckled"})
    Got a banana that is speckled
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In ObjectDataSource we have a method called SelectMethod and TypeName in which we can
I have a method called funct which i want to have as my callback
Suppose that I have a method called doSomething() and I want to use this
I have created a class library called AddServiceLibrary in which I have a method
I have a method called inside a button that run almost an infinite loop.
How to pass parameters to Thread.ThreadStart() method in C#? Suppose I have method called
How to raise combobox_SelectedIndexChanged(object sender, EventArgs e) programmatically? Lets say i have method called
I have a method called FormattedJoin() in a utility class called ArrayUtil . I
If you have a method called set in a class and want to create
Let's say I have a method called foo. What's the difference between: [self foo];

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.