This is almost a perfect example of something that protocols could help
with (http://clojure.org/reference/protocols):

(defprotocol IGetValuePathPairs
  (getValuePathPairs [json]))

(extend-protocol IGetValuePathPairs
  Number
  (getValuePathPairs [json] ...)
  String
  (getValuePathPairs [json] ...))

And since your protocol is defined first, then you can recurse between the
functions just fine.

Timothy


On Thu, Mar 31, 2016 at 11:55 AM, Aaron Cohen <[email protected]> wrote:

>
> On Thu, Mar 31, 2016 at 1:36 PM, Lucas Sloan <
> [email protected]> wrote:
>
>> I have some mutually recursive code as follows:
>>
>>
> Depending on your preferences, either forward declare using "declare" or
> use "letfn".
>
> Your next question will likely be, "How do I make mutually recursive
> functions not run out of stack space?" and the answer for that is
> "trampoline".
>
> https://clojuredocs.org/clojure.core/declare
> https://clojuredocs.org/clojure.core/letfn
> https://clojuredocs.org/clojure.core/trampoline
>
> --Aaron
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to