Re: Write native GUI applications for Windows

2017-12-18 Thread Zz via Digitalmars-d-learn

On Monday, 18 December 2017 at 08:49:51 UTC, Binghoo Dang wrote:

On Monday, 18 December 2017 at 07:55:25 UTC, Andrey wrote:

Hello!
I have a question about creating native GUI applications for 
Windows 7 or/and Windows 10.
I know that exist DWT, DlangUI and other... But I'm 
interesting in native GUI. If it will be C++ then I would use 
WinAPI from SDK.
And what about D? What should I do? Make some kind of wrapper 
above C WinApi?
I also know that on GitHub exists such wrapper 
(https://github.com/AndrejMitrovic/DWinProgramming) but it is 
old - last commit was 4 years ago.


Could you help me?


You can use libuid which can be found here 
https://code.dlang.org/packages/libuid.


It wrapped the native os gui for d, and it's cross-platform.


Any chance of having a version that allows static linking?

Zz


ndslice help.

2015-12-30 Thread Zz via Digitalmars-d-learn

Hi,

Just playing with ndslice and I couldn't figure how to get the 
following transformations.


given.

auto slicea = sliced(iota(6), 2, 3, 1);
foreach (item; slicea)
{
   writeln(item);
}

which gives.

[[0][1][2]]
[[3][4][5]]

what transformation should i do to get the following from slicea.

[[0][2][4]]
[[1][3][5]]

[[4][2][0]]
[[5][3][1]]

Zz






Re: ndslice help.

2015-12-30 Thread Zz via Digitalmars-d-learn
On Wednesday, 30 December 2015 at 20:43:21 UTC, Ilya Yaroshenko 
wrote:

On Wednesday, 30 December 2015 at 18:53:15 UTC, Zz wrote:

Hi,

Just playing with ndslice and I couldn't figure how to get the 
following transformations.


given.

auto slicea = sliced(iota(6), 2, 3, 1);
foreach (item; slicea)
{
   writeln(item);
}

which gives.

[[0][1][2]]
[[3][4][5]]

what transformation should i do to get the following from 
slicea.


[[0][2][4]]
[[1][3][5]]

[[4][2][0]]
[[5][3][1]]

Zz


Hi,

void main()
{
auto slicea = sliced(iota(6), 2, 3, 1);
auto sliceb = slicea.reshape(3, 2, 1).transposed!1;
auto slicec = sliceb.reversed!1;

writefln("%(%(%(%s%)\n%)\n\n%)", [slicea, sliceb, slicec]);
}

Output:
[0][1][2]
[3][4][5]

[0][2][4]
[1][3][5]

[4][2][0]
[5][3][1]

Ilya


Thanks


ndslice help

2016-02-17 Thread Zz via Digitalmars-d-learn

Hi,

I'm trying to generate the following sequences with ndslice.

0 0 0
1 1 1

1 1 1
0 0 0

0 1 2
0 1 2

2 1 0
2 1 0

It's okay with loops but was checking to see if it's possible 
with ndslice.


Zz


Re: ndslice help

2016-02-18 Thread Zz via Digitalmars-d-learn

On Thursday, 18 February 2016 at 02:24:20 UTC, ZombineDev wrote:

On Thursday, 18 February 2016 at 00:25:09 UTC, Zz wrote:

Hi,

I'm trying to generate the following sequences with ndslice.

0 0 0
1 1 1

1 1 1
0 0 0

0 1 2
0 1 2

2 1 0
2 1 0

It's okay with loops but was checking to see if it's possible 
with ndslice.


Zz


Here's my solution:
http://dpaste.dzfl.pl/29676608fd88

The best part about ndslice is that you can use the ordinary 
slice operations with it like:

http://dlang.org/spec/arrays.html#array-copying,
http://dlang.org/spec/arrays.html#array-setting,
http://dlang.org/spec/arrays.html#array-operations, etc.

and also leverage the existing ranges, range transformations 
and algorithms from

http://dlang.org/phobos/std_range and
http://dlang.org/phobos/std_algorithm.

In addition, I used nested array formatting with
http://dlang.org/phobos/std_format.


Thanks

Zz


Guide - Migrating from std.experimental.ndslice to mir-algorithm

2017-06-02 Thread Zz via Digitalmars-d-learn

Hi,

Just tried migrating from std.experimental.ndslice to 
mir-algorithm.


Is there a guide on how migrate old code?

I used the following imports before and using then with ndslice.

import std.experimental.ndslice;
import std.algorithm : each, max, sort;
import std.range : iota, repeat;

simplified example of how it was used.
auto a = cr.iota.sliced(r, c);
auto b = a.reshape(c, r).transposed!1;

auto c = a.reversed!1;
auto d = a.reshape(c, r).transposed!1.reversed!1;

auto f = new int[cr].sliced(r, c);
auto h = f.transposed(1);

how can I do the following in mir-algorithm.

Note: I will be going through the documentation.

Zz





Re: Guide - Migrating from std.experimental.ndslice to mir-algorithm

2017-06-03 Thread Zz via Digitalmars-d-learn

On Saturday, 3 June 2017 at 05:21:13 UTC, 9il wrote:

On Friday, 2 June 2017 at 16:08:20 UTC, Zz wrote:

Hi,

Just tried migrating from std.experimental.ndslice to 
mir-algorithm.


Is there a guide on how migrate old code?

I used the following imports before and using then with 
ndslice.


import std.experimental.ndslice;
import std.algorithm : each, max, sort;
import std.range : iota, repeat;

simplified example of how it was used.
auto a = cr.iota.sliced(r, c);
auto b = a.reshape(c, r).transposed!1;

auto c = a.reversed!1;
auto d = a.reshape(c, r).transposed!1.reversed!1;

auto f = new int[cr].sliced(r, c);
auto h = f.transposed(1);

how can I do the following in mir-algorithm.

Note: I will be going through the documentation.

Zz


Hello Zz,

std.experimental.ndslice -> mir.ndslice

std.range : iota, repeat -> mir.ndslice.topology: iota, repeat;
std.algorithm : each; -> mir.ndslice.algorithm: each;
std.algorithm : max; -> mir.utility: max;
std.algorithm : sort; -> mir.ndslice.sorting: sort;


Note, that Mir functions has different semantics compared with 
Phobos!
For example, each iterates deep elements, so should be combined 
with `pack` to iterates rows instead of elements.


Ndslices work with Phobos functions but it is suggested to use 
Mir analogs if any.


// Mir's iota! It is already 2D ndslice :-)
auto a = [r, c].iota;

auto b = a
   // returns flattened iota, a has Contiguous kind,
   // so the result type would be equal to `iota(r*c)`
.flattened
// convert 1D iota ndslice to 2D iota ndslice
.sliced(c, r)
// It is required to use transposed
// Convert ndslice kind from Contiguous to Universal.
.universal
// Transpose the Universal ndslice
.transposed;

auto c = a.universal.reversed!1;
auto d = a.flattened.sliced(c, 
r).universal.transposed!1.reversed!1; // see also `rotated`


auto f = slice!int(c, r); // new int[cr].sliced(r, c); works 
too.

auto h = f.universal.transposed(1);

---
Mir ndslices have three kinds: 
http://docs.algorithm.dlang.io/latest/mir_ndslice_slice.html#.SliceKind


If you have any questions feel free to ask at the Gitter:
https://gitter.im/libmir/public

Best,
Ilya

Best,
Ilya


Thanks


Question regarding mir.csv.

2023-11-01 Thread Zz via Digitalmars-d-learn

Hi,

Currently using std.csv and would like to do the following using 
mir.csv.


auto data = std.csv.csvReader!Layout(input).array;

Are there any examples out there on using mir.csv?

Regards,
Zz


jsoniopipe - exaples?

2023-12-29 Thread Zz via Digitalmars-d-learn

Hi,

Here are some samples from the std.json documentation.
Any idea on how to do something similar using jsoniopipe?

Directly copied from https://dlang.org/phobos/std_json.html

import std.conv : to;

// parse a file or string of json into a usable structure
string s = `{ "language": "D", "rating": 3.5, "code": "42" }`;
JSONValue j = parseJSON(s);
// j and j["language"] return JSONValue,
// j["language"].str returns a string
writeln(j["language"].str); // "D"
writeln(j["rating"].floating); // 3.5

// check a type
long x;
if (const(JSONValue)* code = "code" in j)
{
if (code.type() == JSONType.integer)
x = code.integer;
else
x = to!int(code.str);
}

// create a json struct
JSONValue jj = [ "language": "D" ];
// rating doesnt exist yet, so use .object to assign
jj.object["rating"] = JSONValue(3.5);
// create an array to assign to list
jj.object["list"] = JSONValue( ["a", "b", "c"] );
// list already exists, so .object optional
jj["list"].array ~= JSONValue("D");

string jjStr = 
`{"language":"D","list":["a","b","c","D"],"rating":3.5}`;

writeln(jj.toString); // jjStr


Regards,
Zz


Re: jsoniopipe - exaples?

2023-12-30 Thread Zz via Digitalmars-d-learn
On Saturday, 30 December 2023 at 01:30:22 UTC, Steven 
Schveighoffer wrote:

On Friday, 29 December 2023 at 08:09:58 UTC, Zz wrote:

But yeah, I could ingest all the functionality from std.json 
there. Or maybe even just use `JSONValue` from std.json. Could 
you make an issue?


-Steve


Hi Steve,

It would be a welcome addition.

Regards,
Zz







How pretty-print a struct?

2022-03-30 Thread ZZ via Digitalmars-d-learn

Hi,

Is there an easy way to pretty-print a struct which also includes 
arrays?


pretty_array does a very good job for arrays.

ZZ


Re: How pretty-print a struct?

2022-03-31 Thread ZZ via Digitalmars-d-learn

On Thursday, 31 March 2022 at 16:08:19 UTC, mw wrote:

On Thursday, 31 March 2022 at 06:35:15 UTC, ZZ wrote:

Hi,

Is there an easy way to pretty-print a struct which also 
includes arrays?


pretty_array does a very good job for arrays.




If you want the field variable names in the output, you can use:


https://code.dlang.org/packages/jdiutil

https://code.dlang.org/packages/boilerplate


Thanks.