On Wednesday, 4 December 2019 at 22:51:45 UTC, Steven
Schveighoffer wrote:
I localized that the leak was actually being caused by
websockets. I want to write down my experience because I did some
weird stuff which seems to be working but I want to learn how it
actually make sense and works.
On Wednesday, 4 December 2019 at 14:44:43 UTC, Ola Fosheim
Grøstad wrote:
When is there a noticable difference when using const values
instead of immutable values in a function body? And when should
immutable be used instead of const?
f(){
const x = g();
immutable y = g();
... do stuff w
On Wednesday, 4 December 2019 at 15:38:36 UTC, Steven
Schveighoffer wrote:
On 12/4/19 3:10 AM, Erdem wrote:
I am used to have cool tools like valgrid massif to visualize
the memory usage from C++ but in D it seems I am blind folded
looking for the problem.
Until now I tried:
--vgc option whi
I have simplified my problem which can be seen below.
import std.stdio;
import vibe.core.core;
import vibe.core.concurrency;
import vibe.data.json;
void main()
{
int[] list;
bool ListManipulator(ref int[] list)
{
list ~= 2;
list ~= 4;
return true;
}
On Monday, 18 November 2019 at 21:14:53 UTC, Steven Schveighoffer
wrote:
On 11/18/19 3:53 PM, kerdemdemir wrote:
Is there any way to remove list of elements efficiently with a
dynamical array?
It seems kind of silly that it's not allowed, but maybe it will
be possible after the deprecation i
On Monday, 18 November 2019 at 20:48:40 UTC, kerdemdemir wrote:
On Monday, 18 November 2019 at 20:37:50 UTC, Steven
Schveighoffer wrote:
If I follow the code correctly, it's treating your array as a
tuple of pos/len to remove.
So it looks like your code is equivalent to
remove(tuple(0, 2));
On Monday, 18 November 2019 at 20:37:50 UTC, Steven Schveighoffer
wrote:
If I follow the code correctly, it's treating your array as a
tuple of pos/len to remove.
So it looks like your code is equivalent to
remove(tuple(0, 2));
Which is probably not what you want.
This probably explains why
int[] removeList;
for ( int i = 0; i < tempMap[0].length; i++ )
{
if ( i%2 == 0 )
removeList ~=i;
}
writeln(removeList); (prints 0,2,4)
tempMap[1].remove(0,2,4);
tempMap[2].remove(removeList);
tempMap[3].remove(tuple(0,1),tuple(2,3),tuple(4,5) );
I know my example can be shortened but please excuse me that I am
pasting directly
import std.stdio;
import std.math;
import std.range;
import std.algorithm;
import std.typecons;
int[][4] tempMap;
void main()
{
int[] temp = [ 1, 2, 3 , 4 ,5 ];
tempMap[0] = temp.dup;
tempMap[1] =
How can I configure a fixed ratio between x and y axes in ggplotd
?
I easily found what I am looking for in ggplot which ggplotd
inspires a lot.
http://www.cookbook-r.com/Graphs/Axes_(ggplot2)/
But ggplotd documentation does not have any info about that. Even
I go through the source code spe
On Sunday, 10 March 2019 at 09:43:59 UTC, Dennis wrote:
On Sunday, 10 March 2019 at 08:59:59 UTC, kerdemdemir wrote:
Can I avoid for loops and solve my problem with std algorithms
or ranges ?
Try slide: https://dlang.org/phobos/std_range.html#slide
And then use map.
I think that will work th
I have an array like(In my real problem my data structs is more
complex ) :
auto a = [2,3,4,5,6,7];
I want to apply a operation in a fashion like :
[ 2 , 3 ] --> apply foo and get return result -1
[ 3 , 4 ] ---> -1
[ 4 , 5 ] ---> -1
and so on...
operation might
I have two numbers
First The price = 0.0016123
Second Maximum allowed precision = 0.0001(it can be only
0.001, 0.0001, 0.1, ..., 0.01 bunch of zeros and than
a one that is it)
Anything more precise than the allow precision should truncated.
So in this case 0.0016123 s
Hi
vibe.d has a client implementation.
http://vibed.org/api/vibe.http.websockets/WebSocket
It is as simple as :
auto ws_url =
URL("wss://stream.binance.com:9443/ws/ethbtc@aggTrade");
auto ws = connectWebSocket(ws_url);
if ( !ws.connected )
return;
while ( true )
I am blocked in my project because of an issue while using
websockets.
I can simplify my problem like :
auto ws_url =
URL("wss://stream.binance.com:9443/ws/ethbtc@aggTrade");
auto ws = connectWebSocket(ws_url);
if ( !ws.connected )
return;
sleep(2.seco
After a big refactor my code crushes I have no idea where.
I am only getting :
Program exited with code -11
And a core file.
I used to use gdb for c++ coredumps. With what program&option I
can check dmd core file?
Erdemdem
On Friday, 30 March 2018 at 17:58:23 UTC, Seb wrote:
On Friday, 30 March 2018 at 16:47:52 UTC, kerdemdemir wrote:
Hi,
In vibe's web
page(http://vibed.org/api/vibe.data.json/serializeToJson) it
is told that I should implement
[...]
I think you are looking for this -
https://github.com/vib
On Friday, 30 March 2018 at 17:58:23 UTC, Seb wrote:
On Friday, 30 March 2018 at 16:47:52 UTC, kerdemdemir wrote:
Hi,
In vibe's web
page(http://vibed.org/api/vibe.data.json/serializeToJson) it
is told that I should implement
[...]
I think you are looking for this -
https://github.com/vib
Hi,
In vibe's web
page(http://vibed.org/api/vibe.data.json/serializeToJson) it is
told that I should implement
Json toJson() const;
static T fromJson(Json src);
string toString() const;
static T fromString(string src);
I think I should implement those as member functions(I am not
sure).
I need a classifier in my project.
Since it is I believe most easy to implement I am trying to
implement logistic regression.
I am trying to do the same as the python example:
https://beckernick.github.io/logistic-regression-from-scratch/
I need to data sets with which I will test.
This wo
In documentation and forums I found some example for overloading
opCmp for int values. But I couldn't see any examples for double
values.
That is what I come up with my own:
struct AdjustableVal ( T = double )
{
this ( T initVal )
{
curVal = initVal;
On Saturday, 23 December 2017 at 15:58:27 UTC, Seb wrote:
On Saturday, 23 December 2017 at 15:45:33 UTC, Mike Franklin
wrote:
On Saturday, 23 December 2017 at 15:04:30 UTC, kerdemdemir
wrote:
Is there any better way for me to search C/C++ equivalent
features? As a humble suggestion would it m
I needed to find equivalent of member initialization list in D.
After searching ~10 minutes I found D has very elegant solution
(https://dlang.org/spec/class.html#field-init) after reading
through whole constructor page. My question is not technical this
time I have my solution. But I think whe
On Friday, 22 December 2017 at 23:33:55 UTC, Mengu wrote:
On Thursday, 21 December 2017 at 21:11:58 UTC, Steven
Schveighoffer wrote:
On 12/21/17 4:00 PM, kerdemdemir wrote:
I have a case like :
http://rextester.com/NFS28102
I have a factory method, I am creating some instances given
some enu
I want to make a logging function for member variables by using
reflection.
import std.stdio;
class D : B
{
override void foo() {
a = 4.0;
b = 3.0;
}
double a;
double b;
}
class B
{
void Log()
{
auto a = [__traits(derivedMembers, D)];
f
I have a case like :
http://rextester.com/NFS28102
I have a factory method, I am creating some instances given some
enums.
My question is about :
void PushIntoVector( BaseEnum[] baseEnumList )
{
Base[] baseList;
foreach ( tempEnum; baseEnumList )
{
baseList ~= Factory(temp
enum
{
a = "foo",
b = "bar",
c = "baz";
}
is identical to
enum a = "foo";
enum b = "bar";
enum c = "baz";
Thanks Jonathan I think that changes my point of perspective.
And Jacob Carlborg I like the third option a lot with aliases
good to know that
enum Foo : string
{
KErde
What I meant with anonymous enums was:
https://dlang.org/spec/enum.html#anonymous_enums. Maybe I
couldn't explain well but I believe D have anonymous enums. I am
sorry I have forgotten to remove " :string" in my example from
the "enum : string". Please stretch out ": string" part my
problem is
I have an enum statement :
enum : string
{
KErdem
Ali
Zafer
Salih
//etc...
}
I don't want to give a name to my enum class since I am accessing
this variables very often.
But I also have a function like:
double ReturnCoolNess( /* Is there any way? */ enumVal )
{
switch
On Saturday, 16 December 2017 at 20:56:26 UTC, ketmar wrote:
kerdemdemir wrote:
As far as I know scope(failure) should be collecting all
failure cases.
nope. `failure` scope won't stop exception propagation, it is
just called before exception leaves your function, to give you
a last chance
While calling this function :
bool PublicMarketCall( ref Json result )
{
string fullUrl =
"https://bittrex.com/api/v1.1/public/getmarketsummaries";;
Json data;
try
{
requestHTTP(fullUrl,
(scope req) {
req.method = HTTPMethod.GET;
Hi,
I need to have the same result while using :
openssl dgst -sha256 -hmac "somestring"
But the server rejecting my generated hmac with the code below .
auto hmac = HMAC!SHA256("somestring".representation);
hmac.put(url.representation);
auto generatedHmac = hmac.finish();
string generatedHma
I need to init and push some values into a array something like:
//DMD64 D Compiler 2.072.2
import std.stdio;
import std.array;
void main()
{
bool a = true;
bool b = false;
bool c = false;
bool[] boolList;
auto boolListAppender = boolList.appender();
boolListAppender ~=
On Saturday, 18 November 2017 at 14:30:29 UTC, Adam D. Ruppe
wrote:
On Saturday, 18 November 2017 at 14:22:19 UTC, kerdemdemir
wrote:
bool foo( bool function( double ) controlFoo )
Change that `function` to `delegate` and it should work.
Function pointers aren't allowed to access other local
I am using vibe.d's json(http://vibed.org/api/vibe.data.json/)
module without a problem and really happy with it. There are also
some
examples(https://github.com/vibe-d/vibe.d/tree/master/examples/json). If you are using "dub" package manager it is also very easy to integrate vibe.d.
//DMD64 D Compiler 2.072.2
import std.stdio;
bool foo( bool function( double ) controlFoo )
{
return controlFoo(5.0);
}
void foo2( double val )
{
writeln ( foo( a => a > val ) );
}
void main()
{
foo2(20);
writeln("Hello, World!");
}
Does not compile and gives this errors:
sou
I'd take a look at why the error message says
`Future!(UserData)[]) to Future!(AnalyzeData)[]`
is AnalyzeData the type returned by ProcessResponceData?
Alternatively you could use a singly linked list and splice out
elements that pass the filter predicate. I think you'd have to
roll your own t
I am trying to make non blocking web requests to a web service.
vibe.core.concurrency.Future!(UserData)[] futurelist;
// I will make http requests in for loop and push them to
futureList
foreach( elem; elemList )
{
// In makeWebRequest I make the httprequest, parse json
and push to my
On Friday, 13 October 2017 at 12:55:09 UTC, piotrklos wrote:
I have windows 10, VS Code with code-d and C/C++ language
extensions. I try to debug but it doesn't work. In particular,
the debugging doesn't stop on breakpoints. It exits
immediately. I recompile with -m64 and -g. I use dub to build
On Friday, 13 October 2017 at 16:36:06 UTC, Ali Çehreli wrote:
On 10/13/2017 08:47 AM, kerdemdemir wrote:
> I changed my dependency setting in dub file to "dcompute":
"~>0.0.0" but
> still getting the same error message. By the way I am sure my
LDC
> version is good because I can build DCompute
On Sunday, 8 October 2017 at 07:51:12 UTC, Nicholas Wilson wrote:
On Saturday, 7 October 2017 at 10:34:15 UTC, kerdemdemir wrote:
do you set "-mdcompute-targets=cuda-xxx" in the dflags for
your dub.json for your project?
I have added now after your comment.
But it seems it didn't changed anyt
On Saturday, 7 October 2017 at 12:12:10 UTC, kinke wrote:
On Saturday, 7 October 2017 at 09:04:26 UTC, kerdemdemir wrote:
Error: static assert "Need to use a DCompute enabled compiler"
Are you using latest LDC 1.4? The CUDA backend wasn't enabled
for earlier versions.
Yes I am. Actually I
do you set "-mdcompute-targets=cuda-xxx" in the dflags for your
dub.json for your project?
I have added now after your comment.
But it seems it didn't changed anything.
Here is the dub.json file I have:
{
"name": "dsharpear",
"authors": [
"Erdem"
],
You should add DCompute as a DUB dependancy.
Hi,
I inited my project with Dub by unsing "dub init DSharpEar" and
I added dependency "dcompute".
Even I give extra parameters for using ldc.
dub build --compiler=D:\LDCDownload\bin\ldc2.exe --force
I am getting :
Error: static assert "Need
I am a total beginner but I want to post that a lot.
auto autoCorrelation(R)(R range)
if (isRandomAccessRange!R)
{
import std.numeric : fft, inverseFft;
import std.range : chain, repeat, zip, dropBack;
import std.algorithm : map;
import std.complex;
Hi,
I have a cuda kernel already working in my cpp
project(https://github.com/kerdemdemir/CUDABeamformer/blob/master/CudaBeamformer/kernel.cu)
I am trying to convert this to D with using DCompute. I already
compiled the DCompute source code and have dcompute.lib. But I am
really not good wit
Hi,
Thanks its price dropped to 10 Euros I bought the the D Web
Development book and I were trying to build some examples.
The example in Chapter3 called noteapp4 is giving me this error :
Performing "debug" build using dmd for x86.
noteapp4 ~master: building configuration "application"...
C:\
I haven't yet dug into formattedRead but thx for letting me
know : )
I was mostly speaking about the pattern with the AA. I guess
the best I can do is a templated function to hide the ugliness.
ref Value GetWithDefault(Value)(ref Value[string] map, const
(char[]) key) {
auto pValue = key i
We have awesome way for creating slices like:
a = new int[5];
int[] b = a[0..2];
But what about if I have 2D array and I don't want to go
vertical. Something like :
int[3][3] matrix = [
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
];
I believe I can use std.range function "Round
As for the problem itself, it can be solved without finding
connected components. I won't post the solution right away
because it is potentially a spoiler. See
http://codeforces.com/blog/entry/53268 for problem analysis
(828B) and
http://codeforces.com/contest/828/submission/28637184 for an
Of course now I will try to have it work first. Than replace for
loops with Cartesian product calls. Than I will make 2D array
template and even maybe with random access range. And finally for
being able to use this class later in the some other coding
challenge I will make Searching( == 'W' pa
Hi Guys,
@Nicholas , thanks a lot for cool solution but actually I weren't
working on image processing. I was trying to solve
"http://codeforces.com/contest/828/problem/B";. I really needed
finding connected components this time.
@Ivan, your solution is much more elegant than what I did. But
My goal is to find connected components in a 2D array for example
finding connected '*'
chars below.
x x x x x x
x x x x x x
x x * * x x
x x * * x x
x x x * * x
* x x x x x
There are two connected '*' group in this example. First group is
composes of six '*
Hi,
I am tring to build Cristi Cobzarenco's fork of Scid which has
LAPACK,BLAS dependency.
I add all modules of Scid to my project and I am tring to build
it within my project.
I add LibraryFiles: liblapack.a libblas.a libtmglib.a
libgfortran.a etc.. via menu
configuration properties-->Lin
Sad times with linear algebra libraries for me,
Since I can't get rows and columns easily with Scid, It seems
not flexible for me. And also there are other issues for example
I can't set matrix to row or column major.
I begin to check alternatives first I begin to investigate Dlib.
D lib ma
Hi,
I want to use Scid matrixes for implementing GMM algorithm. I
will start by writing Naive Bayes with linear and quadratic
decision boundaries .
I reliaze Scid does not provides any functions for getting
spesific row or coloumn. Matrixwview class only supplies opIndex
function.
Is the
This question is not only about "D linear algebra libraries" but
also for other linear algebra libraries in other languages.
I am working with some scientific developers in my current
project.
When we were talking I said "I know a great linear algebra
library LAPACK" but my friend who is ver
On Saturday, 27 June 2015 at 12:17:31 UTC, Timon Gehr wrote:
This computes a²·a̅ instead of a·a̅.
What is the source code for residualPowerOf2?
Also is there any performance issues? can I make this faster?
Probably you should use
http://dlang.org/phobos/std_complex.html#.sqAbs instead. Y
On Saturday, 27 June 2015 at 10:37:08 UTC, Rikki Cattermole wrote:
No idea about the maths behind it are but:
Thanks a lot for your answer anyway. I am hoping even not related
with D directly, this discussions may atract people from other
languages to D while looking for Domain information.
Hi
My question is more about Maths than D lang,
I am hoping, maybe somebody worked with AutoCorrelation function
before.
auto autoCorrelation(R)(R range)
if (isRandomAccessRange!R)
{
auto residual = residualPowerOf2(range.length); // Find how
many zeros to add
auto fftResult
Hi
I want to read wav files. I thought I can use libsndfile since I
am quite familiar with it.
I downloaded the project from.
https://github.com/D-Programming-Deimos/libsndfile
I add the sndfile.di file to my project.
I thought I could directly use libsndfile.dll since D directly
supports
On Sunday, 21 June 2015 at 10:06:15 UTC, biozic wrote:
You can use a template alias parameter with a default value
that is your default lambda:
int indexOfMax(alias fun = a => a, R)(R range)
{
// Use `fun` here like a function.
}
-- Nico
Thanks a lot, it works !!
Hi,
I need to find the index of maximum element so my code:
int indexOfMax(R)(R range)
{
alias Type = typeof(range.front().re); > I don't like
.re here
Type max = 0;
size_t maxIndex = 0;
foreach ( index,elem; range )
{
if ( elem.re > max )-> And
On Saturday, 13 June 2015 at 13:09:20 UTC, Dennis Ritchie wrote:
auto stringB = readln.chomp.map!(to!dchar).array;
auto stringC = readln.chomp.map!(to!dchar).array;
auto charAppender = appender!(dchar[][]);
auto totalStr = stringB.repeat(3).chain(stringC.repeat(5));
charAppender.put(totalStr)
It is the same, but totalStr is not a dchar[]. It's a Result (a
type internal to the chain function ) which is a range. The
foreach loop iterates over Result, which returns dchar[].
So if you try to do something like that :
charAppender.put(totalStr.array), it won't work because
totalStr.arra
The problem is that your appender is a char appender, and you
try to put a dstring into it. Replace :
charAppender.put(totalStr);
by :
foreach(elem; totalStr){
charAppender.put(elem);
}
elem will be a dchar, so it will work.
But I can see in the example of
array.appander(http://dlang
I have two strings(stringB,stringC) which I need to repeat(bCount
times, cCountTimes) and then chain.
auto charAppender = appender!(dchar[]);
auto totalStr =
stringB.repeat(bCount).chain(stringC.repeat(cCount));
This compiles and works ok,
But when I try to append new string to charAppender :
Thanks a lot for your great advices and exaamples. Yes if I don't
return; web-site won't show it as "wrong answer".
As a learner I am very happy with the responsiveness of the
community.
Regards
void foo(R)(R range)
if (isInstanceOf!(Tuple, ElementType!R))// <-- optional
{
Ali thanks a lot. I don't believe I didn't simply try your way.
It works.
I am also happy to learn optional static if . Your examples are
really useful for me.
Next time I will share whole code.
Thanks
Hi;
I have tuples created by std.algorithm.group function.
auto tupleB = stringB.group();
I need to write a a function which takes tubleB and do some cool
stuff. If I don't use a function and write all code below
.group() everytihng works but for reusing the code I want to call
a f
Hi;
To learn D better and challanging myself I am tring code
computation's with D.
There is a question which is about reading a line of integer
which consist of 20 elements.
My solution fails because "Time limit exceeded", I thought it is
because of my algorithm first. I realize time l
I am running DMD on windows, my DMD version is DMD32 V2.067.1.
It might be because I installed 32bit version on 64bit windows.
Hi
Following code works
int[] peopleMoney = iota(0, 500, 1).array();
writeln(peopleMoney.map!(a => to!string(a)).joiner(" "));
=> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...
It writes the contents to std.output as expected.
But if I change 500 to 600 nothing is
Unfortunately not this time :)
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.array; ---> I added this line thanks to you.
The solution may be as simple as importing std.array (or
std.range) but we can't be sure without a short but complete
code.
Solution was as simple as importing std.array. Thanks a lot again
Ali.
Just for curiosity; why can't I use
numArr.take(3);
source\app.d(33): Error: no property 'take'
And one more question out of curiosity why I couldn't find any
method which will return the max element in a range.
auto outputString = (char[][] inParam) =>
(inParam[0].length == 0 || target.startsWith(inParam[0])) &&
(inParam[1].length == 0 || target.endsWith(inParam[1]));
In your case its pretty simple. The buffer is being reused. So
same memory being added multiple times to the candidate.
Just slap on a .dup when adding it.
candidate ~= line;
Thanks a lot replacing the line above with
candidate ~= [line[0].dup, line[1].dup];
My problem is solved .
I want to append a 2D array to my 3D array. I expect it should be
same as int[] arr; arr ~= 3;
void readInput()
{
char[][][] candidate;
char[] buff;
size_t counter = 0;
while ( stdin.readln(buff) )
{
char[][] line = buff.chomp().split();
writeln(line);
79 matches
Mail list logo