On Friday, 18 October 2024 at 12:07:24 UTC, Kadir Erdem Demir
wrote:
It seems [=] functionality C++ does not exist in D.
By using a helper function I made that example work.
[...]
Because 'work' is captured, it is allocated on the heap.
The loops are all assigning values to this 'work' in the
i know the reason,C# have several compares methods.
String.Compare , String.CompareOrdinal
//now the output is same as the D code
Array.Sort(arr, string.CompareOrdinal);
D code:
auto arr = ["b1=1", "b=2","a1=1", "a=2"];
writeln(arr.sort());
output:["a1=1", "a=2", "b1=1", "b=2"]
C# code:
var arr = new string[]{ "b1=1", "b=2", "a1=1", "a=2" };
Array.Sort(arr);
output:["a=2","a1=1","b=2","b1=1"]
If we worry about the string form and instead try:
double reduce_string_loop() {
return reduce!"1.0 / (a * a)"(iota(1, 100));
}
double reduce_function_loop() {
return reduce!((n) => 1.0 / (n * n))(iota(1, 100));
}
it should be write :
double reduce_loop() {
//return iota(1, 100).map!"
On Monday, 7 September 2015 at 14:12:25 UTC, Bahman Movaqar wrote:
I need some help understand the behaviour of my code[1].
Specifically I have trouble with `add` method on line 79.
My impression is that since it returns `this`, multiple
invocations can be chained like `obj.add(X).add(Y).add(
On Saturday, 29 August 2015 at 12:56:08 UTC, cym13 wrote:
Hi,
Let's say I have a simple binary file whose structure is
well-known. Here is
an example which stores points:
struct Point {
long x;
long y;
long z;
}
struct BinFile {
uintmagicNumber; // Some identifier
ul
win7 x86 dmd2.067.1 ok
ubuntu x64 dmd2.067.1 error
-
import std.stdio;
import std.socket;
extern(C)
void recv()
{
writeln("recv...");
}
extern(C)
void send()
{
writeln("send...");
}
int main(string[] argv)
{
//copy from std.socket unittest
win 7 x86,3GB ram:
1. dmd 2.066 vibe-d-0.7.23, it's ok.
2. dmd 2.067 vibe-d-0.7.23,
show error msg "out of memory"
why?
On Wednesday, 25 March 2015 at 00:26:21 UTC, Adam D. Ruppe wrote:
On Wednesday, 25 March 2015 at 00:09:33 UTC, mzf wrote:
i use "implib.exe /system func.lib func.dll" to create a
func.lib.
You might also need to specify the .def file as the final
argument to that.
http://digitalmars.com
On Tuesday, 24 March 2015 at 15:26:22 UTC, Adam D. Ruppe wrote:
try extern(Windows) isntead of extern(C).
use extern(Windows) or extern(System)
the compile show the link error:
Error 42: Symbol Undefined _sub@8
dll export func name is "sub",
and the dll is 3rd party,i can't c
for example:use vc compile on x86
func.c:
__declspec(dllexport) int _stdcall sub(int a,int b)
{
return a-b;
}
func.def:
LIBRARY
EXPORTS
sub
-
i use "implib.exe" to create a omf format lib.
D code:
import std.exception;
//this is a cdecl call
extern(C) i
On Saturday, 7 February 2015 at 06:08:39 UTC, ketmar wrote:
On Sat, 07 Feb 2015 04:30:07 +, Safety0ff wrote:
False pointers, current GC is not precise.
not only that. constantly allocating big chunks of memory will
inevitably
lead to OOM due to current GC design. you can check it with
m
Thanks, my problem has been solved:)
---
import std.stdio;
import core.stdc.wchar_;
extern(C) int setlocale(int, char*);
static this()
{
fwide(core.stdc.stdio.stdout, 1);
setlocale(0, cast(char*)"china");
}
int main(string[] args)
{
string s1 =
On Saturday, 24 January 2015 at 01:54:32 UTC, mzf wrote:
thanks,you are right.
window console show chinese char is not right,
so i try to add this code:
"
extern(C) int setlocale(int, char*);
static this()
{
fwide(core.stdc.stdio.stdout, 1);
setlocale(LC_CTYPE, cast(char*)"china");
}
import std.stdio;
void testGC()
{
auto b = new byte[](1024*1024*100);
writeln("malloc 100M!");
}
void main()
{
foreach(i;1..100)
{
testGC();
}
}
--
core.exception.OutOfMemoryError@(0)
win7 x86,dmd v2.066.0
is there any simple way to convert?
int [] arr1 = [1,2,3].map!"a*2"; //compile error
int [] arr2 = [1,2,3].filter!"a<3";//compile error
thanks,you are right.
window console show chinese char is not right,
so i try to add this code:
"
extern(C) int setlocale(int, char*);
static this()
{
fwide(core.stdc.stdio.stdout, 1);
setlocale(LC_CTYPE, cast(char*)"china");
}
"
it's looks like solve the problem,but caused another proble
i wrote a test code:
void worker(int firstNumber)
{
Thread.sleep(1.msecs);
}
void main()
{
foreach (i; 1 .. 1000) {
spawn(&worker, i );
writeln(i);
}
thread_joinAll();
writeln("ok");
}
sometimes it's ok,sometimes it's crashed ! why ?
here is one of times ca
18 matches
Mail list logo