Re: Android Status

2016-12-31 Thread Joakim via Digitalmars-d-learn

On Saturday, 31 December 2016 at 05:52:00 UTC, Ignacious wrote:

On Thursday, 29 December 2016 at 10:14:53 UTC, Joakim wrote:
On Wednesday, 28 December 2016 at 23:33:57 UTC, Ignacious 
wrote:
What is the current status for building android apps in D? I 
would like to create simple graphic based apps but don't 
wanna get bogged down in trying to get car moving without any 
wheels.


Should all work, but nothing other than small apps have been 
tested.  Try the latest beta, which I just put up:


http://forum.dlang.org/post/xetfqojxijgobisfa...@forum.dlang.org

If you want something more substantive than my ports of the 
NDK's sample apps, check out Vadim's Tetris app, which I spent 
half an hour playing on my phone, :) or his minecraft-like 
demo (click on the sourceforge link from his forum post to get 
the apps):


http://forum.dlang.org/thread/cdekkumjynhqoxvmg...@forum.dlang.org

Let me know if you have any questions or problems.


Is there any way to get a package that works for windows? While 
the steps don't seem too difficult to do, things never go well 
for me(something always breaks... always!)


did install the linux subsystem but... seems like it would be 
easier for you to compile a binary and upload it... since you 
know what you are doing and have everything at hand already...


At least that gives me(and others) the ability to try to build 
the examples and see how it works and all that... then I can go 
through all the trouble of building the compiler myself if it 
seems worth it rather than wasting time.


Sorry, I haven't used Windows in more than a year, ever since my 
ultrabook died.  I've gone full Android since then, which is why 
it is easier for me to provide a native Android compiler than a 
Windows cross-compiler. :) I'm currently typing this message out 
on an Android 5.1" smartphone, propped up on a cheap Chinese 
tablet stand in front of me and hooked up to a full USB keyboard.


In any case, you should be able to use the linux build I provide, 
as you later found.


On Saturday, 31 December 2016 at 06:48:12 UTC, Ignacious wrote:

On Saturday, 31 December 2016 at 06:33:10 UTC, Ignacious wrote:

On Saturday, 31 December 2016 at 05:52:00 UTC, Ignacious wrote:

On Thursday, 29 December 2016 at 10:14:53 UTC, Joakim wrote:

[...]



I see these:

https://github.com/joakim-noah/android/releases

Seems the two archives are identical though except the libs?

Is this what I use to compile the examples?


nvm mind, I guess I accidentally extracted the same archive 
thinking it was the other.


so, essentially these are the two different compilers for the 
two different android architectures?


As mentioned at the top of the release, the first is a native 
Android compiler, meaning you use it on an Android tablet or 
smartphone.  The second is a linux cross-compiler, meaning you 
need a linux/x64 shell from which you cross-compile to 
Android/ARM.


On Saturday, 31 December 2016 at 08:05:42 UTC, Ignacious wrote:

Ok, so I installed
ldc2-android-arm-1.1.0-beta4-linux-x86_64.tar.xz

in to ldcandroid

and tried running

./bin/ldc2 -c test.d

I get the error.

./bin/ldc2: error while loading shared libraries: 
libconfig.so.9: cannot open shared object file: No such file or 
directory


Searched the file system for libconfig and found nothing so I 
did


sudo apt-get install libconfig++9

which installed it under lxss\rootfs\usr\lib\x86_64-linux-gnu

It shows up when I do

sudo ldconfig -v

/usr/lib/x86_64-linux-gnu:
libconfig++.so.9 -> libconfig++.so.9.1.3

I tried adding this:

export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu

But still same issue.

Any ideas how to fix this?


Can you try

sudo apt-get install libconfig9

I don't know if that will install something different, but it's 
the command I see others using online.  Otherwise, check if the 
libconfig++9 package you installed included libconfig.so.9, which 
is what ldc is linked against.  If not, install the package that 
provides that library.  The wiki mentions installing 
libconfig-dev, you could always just install that if nothing else 
works.


Let me know if you run into any other problems.  The Win10 
support is brand new, just added this week, so we don't have much 
experience with it.


Re: Sorted ranges in combined sorted order?

2016-12-31 Thread Matthew Gamble via Digitalmars-d-learn

On Thursday, 20 October 2016 at 22:01:01 UTC, Ali Çehreli wrote:

On 10/20/2016 02:15 PM, Nordlöw wrote:

On Thursday, 20 October 2016 at 21:14:14 UTC, Nordlöw wrote:

Given a range of ranges where individual ranges are already


Ahh, my mistake. It's

https://dlang.org/phobos/std_algorithm_setops.html#.NWayUnion

you're looking for, right?


Thanks! That's exactly what I needed... I consider my "wasted" 
effort of writing such a range just now, as valuable 
experience. :)


And the reason I could not find it is because it didn't occur 
to me that it would be under a *set* module, which the 
RangeOfRanges parameter of nWayUnion has no such requirement 
(i.e. any two range can be equal).


Ali


I've been struggling with a similar issue trying to use NWayUnion 
and merge. It seems to me that the drawback with NWayUnion is 
that it requires the elements of the ranges to be assignable or 
swappable, in addition to the fact that it doesn't give a formal 
union (i.e. there should be no repetition of elements). The 
drawback of merge is that it doesn't work on a RoR at all, so the 
number of ranges to be passed must be know at compile time.


I've rewritten both of these functions so that they can work on a 
RoR that is not assignable or swappable. Of course my nWayMerge 
could be synonymous with nWayUnion by just sending it to uniq(), 
but I though the solution below might be more efficient. I guess 
I'm wondering if there was an easier or better way to do this. I 
pasted the code below in case it would be valuable for others. 
Please let me know if you have any suggestions. And if I did 
something terribly silly please understand, I'm a professional 
scientist, but not a computer scientist (I'm a molecular 
biologist).


P.S. Ali, I a big fan of your book on D; it was the first book I 
read on D and gave me a great start. :)


Thanks, Matt

module nWayMergeAlt;

import std.algorithm;
import std.range;

auto nWayMergeAlt(R)(R[] rs...) if (isForwardRange!R)
{ return NwayMergeAlt!R(rs); }

struct NwayMergeAlt(R) if (isForwardRange!R)
{
this(R[] rs)
{
_source = rs;
_minPosResult = _source.minPos!("a.front() < b.front()")();
}

bool empty() @property const { return _source.length == 0; }

	auto front() @property const { return 
_minPosResult.front().front(); }


void popFront() @property
{
_minPosResult.front().popFront();
if (_minPosResult.front().empty())
			_source = 
_source.remove!(SwapStrategy.unstable)(_source.length - 
_minPosResult.length);
		if (!empty) _minPosResult = _source.minPos!("a.front() < 
b.front()")();

}
private:
R[] _source;
R[] _minPosResult;
}

unittest
{
import std.stdio;
auto a = iota(0,20,2);
auto b = iota(1,20,2);
auto c = iota(0,20);
assert(equal(nWayMergeAlt(a,b), c));
assert(equal(nWayMergeAlt([a,b]), c));

auto d = [1,2,3,4];
auto e = [3,4,5,6];
auto f = [1,2,3,3,4,4,5,6];
assert(equal(nWayMergeAlt(d,e),f));
}

auto nWayUnionAlt(R)(R[] rs...) if (isForwardRange!R)
{
return NwayUnionAlt!R(rs);
}

struct NwayUnionAlt(R) if (isForwardRange!R)
{
this(R[] rs)
{
_source = rs;
_minPosResult = _source.minPos!("a.front() < b.front()")();
_currVal = _minPosResult.front().front();
}

bool empty() @property const { return _source.length == 0; }

auto front() @property const { return _currVal; }

void popFront() @property
{
while(!empty && _currVal == _minPosResult.front().front())
{
_minPosResult.front().popFront();
if (_minPosResult.front().empty())
//_source = 
_minPosResult.remove!(SwapStrategy.unstable)(_source.length - 
_minPosResult.length);
_source = 
_source.remove!(SwapStrategy.unstable)(_source.length - 
_minPosResult.length);
			if (!empty) _minPosResult = _source.minPos!("a.front() < 
b.front()")();

}
if (!empty) _currVal = _minPosResult.front().front();
}
private:
R[] _source;
R[] _minPosResult;
typeof(_source.front().front()) _currVal;
}

unittest
{
import std.stdio;
auto a = iota(0,20,2);
auto b = iota(1,20,2);
auto c = iota(0,20);
//equal((nWayUnion(a,b)),c);//error
assert(equal(nWayUnionAlt(a,b), c));
assert(equal(nWayUnionAlt([a,b]), c));

auto d = iota(0,20);
auto e = iota(5,25);
auto f = iota(0,25);
assert(equal(nWayUnionAlt(d,e),f));
}



Re: Adding linker paths with spaces using dmd and msvc toolchain

2016-12-31 Thread Jeremy DeHaan via Digitalmars-d-learn
On Friday, 30 December 2016 at 21:51:32 UTC, Rainer Schuetze 
wrote:



On 30.12.2016 19:24, Jeremy DeHaan wrote:

On Friday, 30 December 2016 at 04:56:59 UTC, Jerry wrote:
On Friday, 30 December 2016 at 03:51:13 UTC, Jeremy DeHaan 
wrote:

How does one correctly add a linker path that has spaces?


The quotes get consumed by the command line. The way DMD 
spawns the

linker by creating a new string with all the flags.



Does this happen on other platforms too? There has to be a 
GOOD way to
pass a linker path that has spaces. Should this be considered 
as a bug?





Not sure if it qualifies as "GOOD", but this works:

dmd -m64 "-L/LIBPATH:\"path with spaces\"" main.d


Well, it's probably as good as it's going to get without dmd 
looking for this specifically or having something added. Thanks.


Re: Reducing visual clutter.

2016-12-31 Thread Ignacious via Digitalmars-d-learn
On Saturday, 31 December 2016 at 12:31:07 UTC, Nicholas Wilson 
wrote:
On Saturday, 31 December 2016 at 11:39:39 UTC, Nicholas Wilson 
wrote:

[...]


Oh and `kernel` could be a template function that would need 
its args forwarded to it.


Alias it away using a wrapper?


Re: Reducing visual clutter.

2016-12-31 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 31 December 2016 at 11:39:39 UTC, Nicholas Wilson 
wrote:

[...]


Oh and `kernel` could be a template function that would need its 
args forwarded to it.


Reducing visual clutter.

2016-12-31 Thread Nicholas Wilson via Digitalmars-d-learn

so I have

```
struct Pipeline
{
 // some fields.
ref typeof(this) invoke(alias kernel)(TransformArgsOf!kernel 
args)

{
//...
return this;
}
}
```

and it will be used like

```
void fun1(int a) {}
void fun2(double b) {}
void funn(ulong c) {}
//...
auto pipe = Pipeline(...);
pipe.invoke!fun1(42)
.invoke!fun2(3.14)
.invoke!funn(1u)
//...
;
```

is there anyway to reduce the visual noise of the `invoke`?

I was thinking of trying to (ab)use opDispatch + mixins that 
returns a callable whose opCall returns the Pipeline by ref. I'm 
not sure how well that would go given I need `kernel.mangleof`, 
`typeof(kernel)` and `Parameters!kernel`.


Is there a nicer way to achieve this? Or is this shenanigans not 
worth it?




Re: Android Status

2016-12-31 Thread Ignacious via Digitalmars-d-learn

On Thursday, 29 December 2016 at 10:14:53 UTC, Joakim wrote:

On Wednesday, 28 December 2016 at 23:33:57 UTC, Ignacious wrote:
What is the current status for building android apps in D? I 
would like to create simple graphic based apps but don't wanna 
get bogged down in trying to get car moving without any wheels.


Should all work, but nothing other than small apps have been 
tested.  Try the latest beta, which I just put up:


http://forum.dlang.org/post/xetfqojxijgobisfa...@forum.dlang.org

If you want something more substantive than my ports of the 
NDK's sample apps, check out Vadim's Tetris app, which I spent 
half an hour playing on my phone, :) or his minecraft-like demo 
(click on the sourceforge link from his forum post to get the 
apps):


http://forum.dlang.org/thread/cdekkumjynhqoxvmg...@forum.dlang.org

Let me know if you have any questions or problems.


Ok, so I installed
ldc2-android-arm-1.1.0-beta4-linux-x86_64.tar.xz

in to ldcandroid

and tried running

./bin/ldc2 -c test.d

I get the error.

./bin/ldc2: error while loading shared libraries: libconfig.so.9: 
cannot open shared object file: No such file or directory


Searched the file system for libconfig and found nothing so I did

sudo apt-get install libconfig++9

which installed it under lxss\rootfs\usr\lib\x86_64-linux-gnu

It shows up when I do

sudo ldconfig -v

/usr/lib/x86_64-linux-gnu:
libconfig++.so.9 -> libconfig++.so.9.1.3

I tried adding this:

export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu

But still same issue.

Any ideas how to fix this?