Re: Passing functions as template parameter and assigning default values to them

2015-06-21 Thread kerdemdemir via Digitalmars-d-learn
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 !!

Using C library libsndfile with D

2015-06-25 Thread kerdemdemir via Digitalmars-d-learn
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

Autocorrelation function with ranges

2015-06-27 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Autocorrelation function with ranges

2015-06-27 Thread kerdemdemir via Digitalmars-d-learn
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.

Re: Autocorrelation function with ranges

2015-06-27 Thread kerdemdemir via Digitalmars-d-learn
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.

Passing functions as template parameter and assigning default values to them

2015-06-21 Thread kerdemdemir via Digitalmars-d-learn
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

Reading array of integers readln performance issues

2015-06-11 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Writeln does not prints if array has more than 500 elements

2015-06-10 Thread kerdemdemir via Digitalmars-d-learn
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.

Writeln does not prints if array has more than 500 elements

2015-06-10 Thread kerdemdemir via Digitalmars-d-learn
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

How to pass voldemort types to functions

2015-06-12 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Reading array of integers readln performance issues

2015-06-12 Thread kerdemdemir via Digitalmars-d-learn
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

Re: How to pass voldemort types to functions

2015-06-12 Thread kerdemdemir via Digitalmars-d-learn
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

Re: appender!(dchar[]) put fail

2015-06-13 Thread kerdemdemir via Digitalmars-d-learn
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));

Re: appender!(dchar[]) put fail

2015-06-13 Thread kerdemdemir via Digitalmars-d-learn
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

Re: appender!(dchar[]) put fail

2015-06-13 Thread kerdemdemir via Digitalmars-d-learn
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

appender!(dchar[]) put fail

2015-06-13 Thread kerdemdemir via Digitalmars-d-learn
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

Linear algebra library with no dependency Why every linear algebra library has LAPACK dependency

2015-07-03 Thread kerdemdemir via Digitalmars-d-learn
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 very

Getting Nth Row and Column from MatrixView, Scid library

2015-07-17 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Getting Nth Row and Column from MatrixView, Scid library

2015-07-17 Thread kerdemdemir via Digitalmars-d-learn
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

VisualD building with GDC setting library path

2015-07-18 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Avoid if statements for checking neighboring indexes in a 2D array

2017-07-17 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Avoid if statements for checking neighboring indexes in a 2D array

2017-07-16 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Avoid if statements for checking neighboring indexes in a 2D array

2017-07-16 Thread kerdemdemir via Digitalmars-d-learn
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'

Avoid if statements for checking neighboring indexes in a 2D array

2017-07-16 Thread kerdemdemir via Digitalmars-d-learn
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

Best syntax for a diagonal and vertical slice

2017-07-22 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Efficiently streaming data to associative array

2017-08-09 Thread kerdemdemir via Digitalmars-d-learn
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

Error 16: Index Range error while building examples from D Web development

2017-09-17 Thread kerdemdemir via Digitalmars-d-learn
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"...

Need importing dcompute.lib into my project

2017-10-06 Thread kerdemdemir via Digitalmars-d-learn
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

Re: For fun: Expressive C++ 17 Coding Challenge in D

2017-10-06 Thread kerdemdemir via Digitalmars-d-learn
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;

Re: Need importing dcompute.lib into my project

2017-10-13 Thread kerdemdemir via Digitalmars-d-learn
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

Re: debugging in vs code on Windows

2017-10-13 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Need importing dcompute.lib into my project

2017-10-13 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Need importing dcompute.lib into my project

2017-10-07 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Need importing dcompute.lib into my project

2017-10-07 Thread kerdemdemir via Digitalmars-d-learn
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" ],

Re: Need importing dcompute.lib into my project

2017-10-07 Thread kerdemdemir via Digitalmars-d-learn
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

Passing anonymous enums as function parameters

2017-12-17 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Passing anonymous enums as function parameters

2017-12-17 Thread kerdemdemir via Digitalmars-d-learn
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

Scope failure is not preventing application crush in case of uncaught exceptions

2017-12-16 Thread kerdemdemir via Digitalmars-d-learn
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;

Re: Scope failure is not preventing application crush in case of uncaught exceptions

2017-12-16 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Passing anonymous enums as function parameters

2017-12-20 Thread kerdemdemir via Digitalmars-d-learn
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 {

Re: Lambda cannot access frame of function

2017-11-18 Thread kerdemdemir via Digitalmars-d-learn
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

Lambda cannot access frame of function

2017-11-18 Thread kerdemdemir via Digitalmars-d-learn
//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:

Re: Json

2017-11-18 Thread kerdemdemir via Digitalmars-d-learn
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.

One liner alternatives for initing and pushing some values into array

2017-11-20 Thread kerdemdemir via Digitalmars-d-learn
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 ~=

Problem with digest Hmac sha256 method and another problem while using openssl hmac

2017-12-08 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Removing some of the elements from vibe.core.concurrency.Future[] futurelist

2017-10-31 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Is there websocket client implementation for D

2018-06-11 Thread kerdemdemir via Digitalmars-d-learn
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 )

Connecting two web sockets at the same time with vibe.d

2018-06-02 Thread kerdemdemir via Digitalmars-d-learn
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;

Finding the last executed line by checking dmd core

2018-05-03 Thread kerdemdemir via Digitalmars-d-learn
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 I can check dmd core file? Erdemdem

Removing some of the elements from vibe.core.concurrency.Future[] futurelist

2017-10-28 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Finding equivalent of C++ feature in D documentation.

2017-12-23 Thread kerdemdemir via Digitalmars-d-learn
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

Re: One liner for creating an array filled by a factory method

2017-12-23 Thread kerdemdemir via Digitalmars-d-learn
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

opCmp with double values

2017-12-24 Thread kerdemdemir via Digitalmars-d-learn
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;

Finding equivalent of C++ feature in D documentation.

2017-12-23 Thread kerdemdemir via Digitalmars-d-learn
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

One liner for creating an array filled by a factory method

2017-12-21 Thread kerdemdemir via Digitalmars-d-learn
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 ~=

Converting member variables to strings with using reflection from base class

2017-12-22 Thread kerdemdemir via Digitalmars-d-learn
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)];

Re: How to customize vibe.data.json

2018-03-30 Thread kerdemdemir via Digitalmars-d-learn
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 -

Re: How to customize vibe.data.json

2018-03-30 Thread kerdemdemir via Digitalmars-d-learn
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 -

How to customize vibe.data.json

2018-03-30 Thread kerdemdemir via Digitalmars-d-learn
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).

Making mir.random.ndvariable.multivariateNormalVar create bigger data sets than 2

2018-02-27 Thread kerdemdemir via Digitalmars-d-learn
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

Removing the precision from double

2018-11-01 Thread kerdemdemir via Digitalmars-d-learn
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

ggplotd Fixed ratio between x and y axes

2019-03-11 Thread kerdemdemir via Digitalmars-d-learn
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

Applying a function each respective 2 elements of an array

2019-03-10 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Applying a function each respective 2 elements of an array

2019-03-10 Thread kerdemdemir via Digitalmars-d-learn
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

What is the replacement for deprecated array removal

2019-11-18 Thread kerdemdemir via Digitalmars-d-learn
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] =

Re: What is the replacement for deprecated array removal

2019-11-18 Thread kerdemdemir via Digitalmars-d-learn
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

Re: What is the replacement for deprecated array removal

2019-11-18 Thread kerdemdemir via Digitalmars-d-learn
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)

Re: What is the replacement for deprecated array removal

2019-11-18 Thread kerdemdemir via Digitalmars-d-learn
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));

Re: What is the replacement for deprecated array removal

2019-11-18 Thread kerdemdemir via Digitalmars-d-learn
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

Re: const and immutable values, D vs C++?

2019-12-04 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Profiling the memory in D

2019-12-04 Thread kerdemdemir via Digitalmars-d-learn
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

Re: Profiling the memory in D

2019-12-07 Thread kerdemdemir via Digitalmars-d-learn
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.

Referance usage in async function

2019-11-30 Thread kerdemdemir via Digitalmars-d-learn
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; }