for example i have an array
int[] a = [1,2,3,4,5];
and a function
auto twice = function (int x) => x * 2;
how can i apply the function to each element in a without using a
forloop? - is there a function to do this?
a.foreach(x => x * 2);
a == [2,4,6,8,10]
thx alot! its not important to me that the function is not
evaluated in place
since you gave me such a straight answer i'd like to bother you
with another question :)
for example i have now two ranges:
immutable a = [1,2,3,4];
immutable b = [2,3,4,5];
how do i add the elements in a and b elem
for example and learning purpose i want to create an arithmetic
vector class.
for a vector of arbitrary size i defined my opBinary like this:
class TVector(T,int n)
{
T[n] val;
.
TVector opBinary(string op)(TVector rhs)
{
auto tmp =
zip(val[],rhs.val[]).map!("a[0]"~op~"a[1]")(
alias Vec4f = TVector!(float,4);
alias Vec3f = TVector!(float,3);
class TVector(T,int n)
{
T[n] val;
...
TVector as class does work as expected, as a struct i get the
following errors, but why?
struct Vector.TVector!(float, 4).TVector no size yet for forward
reference
struct Vector.T
On Tuesday, 5 August 2014 at 19:13:31 UTC, Marc Schütz wrote:
On Tuesday, 5 August 2014 at 18:36:35 UTC, ddos wrote:
alias Vec4f = TVector!(float,4);
alias Vec3f = TVector!(float,3);
class TVector(T,int n)
{
T[n] val;
...
TVector as class does work as expected, as a struct i get the
f
i wasn't intentionally creating a functionpointer, i just liked
the syntax x3 ... but i guess i should read into it now :)
thx for you help !
On Tuesday, 5 August 2014 at 19:51:33 UTC, Philippe Sigaud via
Digitalmars-d-learn wrote:
http://pastebin.com/34sbffSa
Your problem comes from lengthS
Hi,
i'm trying to create a dynamic vertex format for opengl, defined
at compiletime by a struct
e.g. struct Vertex {float[3] position, float[3] normal}
i can get the name of all members with this:
auto b = [ __traits(allMembers, VertexType) ];
but i can't iterate them at compiletime because
On Tuesday, 19 August 2014 at 18:25:24 UTC, Justin Whear wrote:
On Tue, 19 Aug 2014 18:15:33 +, ddos wrote:
since i need to setup vertexpointers for opengl at runtime my
next
question? - is it possible to evaluate the traits also at
runtime? but
i'd also like to know how i can iterate the
struct Vec2
{
float[2] vec;
public float length()
{
return sqrt(vec[0]*vec[0]+vec[1]*vec[1]);
}
}
int main(string[] argv)
{
Vec2 test;
Variant v = test;
return 0;
}
The following code fails because Vec2.length() does not return
int ... so Variant is only usable with types that do not have a
method with name length() ?? i'm confused
On Thursday, 18 September 2014 at 21:03:47 UTC, ddos wrote:
struct Vec2
{
float[2] vec;
public float length(
hi guys, firstly this has no direct application, i'm just playing
around and learning
i want to create 100 uniform distributed numbers and print them
my first attempt, just written by intuition:
[0 .. 100].map!(v => uniform(0.0, 1.0).writeln);
i found out i can't write [0 .. 100] to define a si
thx, alot :) works as intended
iota(0,100).map!(v => uniform(0.0,1.0)).writeln;
i wrote a histogram algorithm
i tried to write it the shortest and most "D" way possible ...
please tell me if you see any simpler way of doing it
is there a simpler way of getting the minimum of a range? (by
intuition i tried range.min)
auto numbers = iota(0,1).map!(_ => uniform(0.0,1.
On Tuesday, 10 February 2015 at 12:18:15 UTC, Vlasov Roman wrote:
On Tuesday, 10 February 2015 at 11:55:43 UTC, Daniel Kozák
wrote:
V Tue, 10 Feb 2015 11:44:09 +
Vlasov Roman via Digitalmars-d-learn
napsáno:
On Tuesday, 10 February 2015 at 11:32:32 UTC, bearophile
wrote:
> Vlasov Roman:
hi!
i'm trying to run OpenVG examples in D. So far i have compiled
ShivaVG (an implementation of OpenVG standard) in C++ and created
a shared library. Now i'd like to link my OpenVG.lib with a D
program.
(the library was compiled with msvc2013x86, i'd like to avoid
switching compiler)
to li
progress ... i think
in some forum posts i've read 64bit dmd uses a differnt linker
which supports coff
atleast i can now link my app in 64bit mode without errors
dmd -m64 source/app.d OpenVG.lib
also an exported test function prints to stdout, so my problem is
solved for x64 :)
if anyone co
thanks Rikki!
also if anyone is interested in OpenVG i have now a running demo
in D based on ShivaVG and derelict GLFW3, it's not beautiful but
it works :D
http://imgur.com/ZH0kD0q
i'm pretty impressed how painless the compiling and interfacing
to C was actually :) +1 for D
On Monday, 6 April 2015 at 15:46:32 UTC, Jeremy DeHaan wrote:
Do you even need to use swig? It looks like gdal has a C
interface. I think that htod would be what you're looking for
http://dlang.org/htod.html
+1 for htod if there is a c interface!
Hi!
i'm trying to get devisualization/window [1] working with some
simple opengl calls. I have created a windows with opengl context
using
Window window = new Window(800, 600, "My window!"w,
WindowContextType.Opengl);
If i run
writeln("type: ", context.type);
writeln("toolkit version: ", c
it's getting warmer, window doesnt freeze anymore and opengl
calls don't crash the window, but it's still all white after
calling
glClearColor(1,0,1,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
updated src:
https://github.com/oggs91/OpenVG_D/blob/master/demo_DvisualizationWT/source/
On Monday, 6 April 2015 at 22:56:15 UTC, Rikki Cattermole wrote:
On 7/04/2015 10:34 a.m., ddos wrote:
it's getting warmer, window doesnt freeze anymore and opengl
calls don't
crash the window, but it's still all white after calling
glClearColor(1,0,1,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_B
i got two modules
opengvg.d and vg.d
vg.d contains calls to external c functions
openvg.d should wrap and simplify some of those calls
in openvg.d i make public import of submodule vg.d
such that if openvg.d is imported the functions in vg.d can be
called, this works as intended. but as soon as
On Thursday, 9 April 2015 at 05:34:09 UTC, anonymous wrote:
On Wednesday, 8 April 2015 at 22:53:39 UTC, ddos wrote:
why not just make it callable without the alias?
It's to prevent "hijacking": http://dlang.org/hijack.html
thx for the article!
On Wednesday, 8 April 2015 at 17:48:36 UTC, anonymous wrote:
On Wednesday, 8 April 2015 at 12:05:00 UTC, ddos wrote:
vg.d:
module vg;
extern (C) void vgSetParameterfv(VGHandle object, VGint
paramType, VGint count, VGfloat *values);
openvg.d
module openvg;
public import vg;
void vgSetParamet
How do i sanitize a string for database query?
Is there some builtin function?
thx :)
On Tuesday, 21 July 2015 at 17:58:55 UTC, Gary Willoughby wrote:
On Tuesday, 21 July 2015 at 17:23:30 UTC, ddos wrote:
How do i sanitize a string for database query?
Is there some builtin function?
thx :)
Use prepared statements instead.
https://en.wikipedia.org/wiki/Prepared_statement
thx
thx
Looking for a RPC library, thrift looked promising, but i can't
even compile the simple example given here
https://thrift.apache.org/tutorial/d
to compile i've
1. copied the thrift/lib/d/src/thrift folder to my source
directory
2. copied the generated sources ( tutorial and share folder )
int
http://pastebin.com/fknwgjtz
i tried to call fibers in a loop forever, to multiplex some
networking client worker fibers and a listener fiber
it seems to work correctly with for(int i=0;i<1;)
with while(true) i get:
C:\dev\server_client>dub
Building server_client ~master configuration "appli
using DMD32 D Compiler v2.068.0 on windows x64
On Thursday, 17 September 2015 at 19:35:05 UTC, Adam D. Ruppe
wrote:
What's there? Anything after an endless loop is potentially
unreachable and dub treats warnings as errors.
i see, thx
On Thursday, 17 September 2015 at 19:43:02 UTC, H. S. Teoh wrote:
On Thu, Sep 17, 2015 at 07:32:13PM +, ddos via
Digitalmars-d-learn wrote:
http://pastebin.com/fknwgjtz
i tried to call fibers in a loop forever, to multiplex some
networking
client worker fibers and a listener fiber
it
thank you :) works now
hello!
yesterday i got curious about how fibers work, and if the can be
used as a replacement in network programming. so i started
hacking a small example together, which is hopefully useful to
other D beginners too :)
http://pastebin.com/Xg4GJbKE
34 matches
Mail list logo