multimethod Questions
2
Solved
Although the below example seems a bit strange, it's because I'm trying to reduce a fairly large problem I've got at present to a minimal example. I'm struggling to work out how to call into multim...
Ader asked 20/9, 2016 at 4:4
2
Solved
I would like to use overloading in Python. I know it's not possible by design (Python is dynamically typed language), there is quite good thread here on this topic. That's why I could use something...
Shive asked 19/3, 2021 at 16:0
2
Solved
I have a class with two multi methods (multi submit).
I call my multi like this:
$perspective.submit(:message($message.content));
Which gets shipped off to my class:
my $perspective-api = API...
Rhythm asked 25/6, 2019 at 15:46
2
Solved
Can you explain with examples how does retag parameter impacts multi-spec creation? I find multi-spec documentation hard to digest.
Delora asked 29/7, 2017 at 22:11
3
Solved
In Clojure 1.5.0, how can I provide a custom pretty-printer for my own record type, defined with defrecord.
(defrecord MyRecord [a b])
(defmethod print-method MyRecord [x ^java.io.Writer writer]
...
Prosaism asked 2/3, 2013 at 21:14
7
I am researching programming language design, and I am interested in the question of how to replace the popular single-dispatch message-passing OO paradigm with the multimethods generic-function pa...
Pairoar asked 4/3, 2012 at 7:27
2
Solved
I am reading Modern C++ Design Generic Programming and Design Patterns Applied by Andrei Alexandrescu and chapter 11 on multimethods deals exactly with the problem I am trying to solve. All source ...
Insinuating asked 28/4, 2014 at 8:52
3
Solved
I'm playing around with a positional interface for strings. I'm aware of How can I slice a string like Python does in Perl 6?, but I was curious if I could make this thing work just for giggles.
I...
Grison asked 25/7, 2017 at 1:30
2
Solved
Consider this example where a subclass has a multi method with no signature and one with a slurpy parameter:
class Foo {
multi method do-it { put "Default" }
multi method do-it ( Int $n ) { put ...
Turbulent asked 12/7, 2017 at 2:13
1
Solved
I am trying to define a multimethod and its implementation in a separate file. It goes something like this:
In file 1
(ns thing.a.b)
(defn dispatch-fn [x] x)
(defmulti foo dispatch-fn)
In file 2...
Waterrepellent asked 12/7, 2016 at 6:13
1
Solved
I've been reading a bit from http://c2.com/cgi/wiki?ImplementingMultipleDispatch
I've been having some trouble finding reference on how Julia implements multimethods. What's the runtime complexity...
Stearic asked 21/8, 2015 at 15:30
4
Solved
I'm a Clojure novice and was looking for some concrete examples of when to use protocols and when to use multimethods. I know that protocols are generally geared towards creating a type hierarchy a...
Harvison asked 9/11, 2011 at 19:21
1
Solved
The get method on user works if the # api.add_resource(User, '/user/')
line is uncommented, and the other api.add_resource is.
The inverse of that is true to make the post method work.
How can I ...
Nollie asked 16/7, 2014 at 1:53
2
Solved
In http://www.haskell.org/pipermail/haskell-cafe/2007-August/030096.html the typeclass method collide is defined as taking a 2-tuple as its single argument, rather than two "normal" arguments (I th...
Attu asked 9/7, 2014 at 14:20
1
Solved
This is a question about the expressiveness of Clojure vs other languages such as Haskell. The broader issue is solutions to the Expression Problem
This question reached the conclusion that in gen...
Woodworth asked 30/3, 2014 at 4:17
2
Solved
More broadly this question is about various approaches to the expression problem. The idea is that your program is a combination of a datatype and operations over it. We want to be able to add new ...
Polar asked 26/2, 2014 at 11:34
7
Solved
I have following C# code. It works fine; but the GetDestination() method is cluttered with multiple if conditions by using is operator.
In .Net 4.0 (or greater) what is the best way to avoid thes...
Cardboard asked 21/1, 2014 at 14:54
3
Solved
So I want to use java.awt.Color for something, and I'd like to be able to write code like this:
(use 'java.awt.Color)
(= Color/BLUE (- Color/WHITE Color/RED Color/GREEN))
Looking at the core imp...
Telemark asked 12/5, 2013 at 0:16
1
I want my program act differently between primitive types and their wrapper classes, for example:
(defmulti try-type class)
(defmethod try-type Integer [arg]
(println "Integer"))
(defmethod try...
Garrison asked 28/7, 2012 at 16:47
3
Solved
I have some code that uses multi-methods and would ideally like to overload the function (in this case, multi-function) so that I can pass in a higher order function to help with testing, for examp...
Hydroscope asked 25/4, 2012 at 10:16
2
Solved
I apologize if the question is trivial, but some googling is not leading me anywhere. What is the general syntax of defmulti and defmethod? I can write simple multimethods, but I am not sure where ...
Egocentrism asked 31/3, 2012 at 22:22
3
Solved
I've spent some time, trying to understand Clojure multimethods. The main "pro" multimethod argument, as far as I understand, is their flexibility, however, I'm confused with the argumentation of w...
Cowboy asked 11/3, 2012 at 18:33
3
Solved
I have a multimethod that specializes on two parameters:
(defmulti get-tag-type (fn [type tag] [type tag]))
Having the type allows me to group the different defmethod calls into sets:
(defmetho...
Fustigate asked 25/2, 2012 at 1:20
3
Solved
The basic idea of what I want to do is:
def aFunction(string='', dicti={}):
if len(str) > 0:
print('you gave string as input')
if len(dicti) > 0:
print('you gave a dict as input')
aFunct...
Demetra asked 10/2, 2012 at 9:41
1
Solved
I'm converting some Scheme code to Clojure. The original uses a dispatching pattern that's very similar to multimethods, but with an inverted approach to the matching predicates. For example, there...
Benefaction asked 1/10, 2011 at 18:53
1 Next >
© 2022 - 2024 — McMap. All rights reserved.