metaprogramming Questions
1
Solved
First post here, thanks for reading!
Problem: I have a Vector{String} - call it A - where each element is a part of an equation, e.g. the first element of A is "x[1] - (0.8*x[1])". I woul...
Psilocybin asked 17/12, 2020 at 12:4
3
Solved
Both to teach myself about implementing more advanced template constructions than simply basic ones, and becouse they are useful in many circumstances, I'm trying to implement map, filter and simil...
Cognizance asked 18/2, 2013 at 21:3
3
Solved
This is purely an experiment, but I'm wondering if it's possible to get a list of the require'd gems at runtime via some kind of metaprogramming. For example, say I have:
require 'rubygems'
requir...
Newspaperman asked 25/8, 2011 at 12:4
1
Solved
As I'm programming a package in Julia, I've written several functions of the sort:
function scatterplot(data; x_col=:x, y_col=:y)
data |> @vlplot(:circle, x=x_col, y=y_col)
end
Now the thing ...
Sendai asked 24/11, 2020 at 17:2
2
Solved
Consider the following code:
type TestTuple = [
{ test: "foo" },
{
test: "bar";
other: 1;
}
];
type Foo<Prop extends string> = TestTuple extends Record<Prop, stri...
Federico asked 20/11, 2020 at 2:14
10
Solved
I am a fan of static metaprogramming in C++. I know Java now has generics. Does this mean that static metaprogramming (i.e., compile-time program execution) is possible in Java? If so, can anyone r...
Gorton asked 21/9, 2008 at 22:10
5
Is it possible in Haskell to implement a function which returns its own function name?
A possible type could be (a -> b) -> String.
Wilks asked 7/3, 2013 at 13:16
1
Several dumpers exist that can show the names of variables without requiring the programmer to explicitely repeat the name.
› perl -MData::Dumper::Simple -e'my $foo = 42; print Dumper($foo)'
$foo ...
Henry asked 29/9, 2017 at 12:37
1
Solved
In Raku, HOWs must expose a list of archetypes through an archetypes method, which is used to determine what broader features of types a type implements, e.g. parametricity or composability. I noti...
Supplicatory asked 17/9, 2020 at 16:18
2
Solved
I understand that the constexpr keyword can be used to perform compile-time computation in C++. For example:
constexpr int factorial(int n)
{
return n <= 1 ? 1 : (n * factorial(n - 1));
}...
Oneupmanship asked 30/8, 2020 at 19:19
3
Solved
Trying to use define_method inside initialize but getting undefined_method define_method. What am I doing wrong?
class C
def initialize(n)
define_method ("#{n}") { puts "some method #{n}" }
e...
Aromaticity asked 14/10, 2013 at 20:9
3
Solved
I need to assuredly check whether a reflect.Type is an error.
There is no reflect kind for error. What is the formal/idiomatic manner to check for type error in go reflect?
Go Playground Full Ex...
Koenraad asked 6/6, 2015 at 23:16
1
Solved
How can I dynamically create a subclass of my class and provide arguments to its __init_subclass__() method?
Example class:
class MyClass:
def __init_subclass__(cls, my_name):
print(f"Subcla...
Matheny asked 18/8, 2020 at 17:39
15
Solved
C++ is probably the most popular language for static metaprogramming and Java doesn't support it.
Are there any other languages besides C++ that support generative programming (programs that creat...
Lindeman asked 22/9, 2008 at 18:34
2
Solved
I come from a python background and am trying to get up to speed with R, so please bear with me
I have an R file - util.R with the following lines:
util.add <- function(a,b) a + b
util.sub <...
Jonme asked 23/9, 2015 at 18:49
3
Solved
I'm trying to register all the resources that I defined with Flask-RESTFUL using the registry pattern.
from flask_restful import Resource
class ResourceRegistry(type):
REGISTRY = {}
def __new...
Duenas asked 22/3, 2016 at 10:35
2
Solved
I really appreciate the Raku's &?BLOCK variable – it lets you recurse within an unnamed block, which can be extremely powerful. For example, here's a simple, inline, and anonymous factorial fun...
Nigritude asked 25/7, 2020 at 21:56
3
Solved
Is there a way to test private methods in Raku?
I understand that one should ideally define their tests targeting the public methods, but is there a way to do it "the wrong way"? :)
I ini...
Phenyl asked 18/7, 2020 at 22:33
3
Solved
I want to retrieve the local variables from Python from a called function. Is there any way to do this? I realize this isn't right for most programming, but I am basically building a debugger. For ...
Endoskeleton asked 8/7, 2011 at 0:47
4
Solved
Given this template:
template <class A>
struct Something {
... // members common to all template instantiations for all A types
SpecialType member; // but not this - I want this to be con...
Agnostic asked 13/4, 2012 at 11:48
1
Solved
I am trying to learn meta-programming in dotty. Specifically compile time code generation. I thought learning by building something would be a good approach. So I decided to make a CSV parser which...
Milline asked 11/7, 2020 at 18:57
6
Solved
I was trying to generate a class from a dictionary:
class attr:
for key in objects_type:
setattr(attr, key, lambda cl: list())
This gives the error that attr is not defined during the for loop...
Cart asked 15/2, 2010 at 10:58
1
I have read this and but i still do not know how to make this work with -std=gnu++2a
I am not sure how to use integer seq. Could you please help me with adapting the below code so that it compiles?...
Outfox asked 3/7, 2020 at 1:36
1
Solved
I was trying to use tidyr::complete inside my function while providing the variable names using {{}}. This works fine, however, when I add a nesting function to combine two variables I get an error...
Casar asked 2/7, 2020 at 14:21
4
Solved
I'm wondering what the difference is between using a static const and an enum hack when using template metaprogramming techniques.
EX: (Fibonacci via TMP)
template< int n > struct TMPFib {
...
Detrital asked 31/1, 2010 at 17:47
© 2022 - 2024 — McMap. All rights reserved.