On 2019-06-11 17:34:00 +, Paul Backus said:
It's a space/time tradeoff. foreach with canFind is O(n^2) time and O(1) space.
Yes, that's why I asekd. They haystack is most likely >10 times larger
than the needles. Speed has priority.
If you use an associative array or a set, it's O(n)
When parsing an xml file I get #text for tagName on basically
every other element.
I'm trying to recurse through all the elements
using
void recurse(T)(T parent, int depth = 0)
{
foreach(c; parent.children)
{
recurse(c,
On Tuesday, 11 June 2019 at 05:15:17 UTC, Markus wrote:
I have cleaned it up, kind of. Just in case you want to compile
it. The Zip contains some DLL from
https://github.com/spatialaudio/portaudio-binaries where you
can find the original if you want.
https://gofile.io/?c=NpUxrJ
I'm in
https://run.dlang.io/is/s4cfiv
onlineapp.d(23): Error: static variable A cannot be read at
compile time
onlineapp.d(23): Error: cannot implicitly convert expression 1 of
type int to int*
I see no reason the code should not work, and the second error
message make no sense.
please
On Tuesday, 11 June 2019 at 17:12:17 UTC, Robert M. Münch wrote:
Is there a simple and elegant way to do this? Or is just using
a foreach(...) with canFind() the best way?
There are two versions of find that can find a range within
another:
On Wed, Jun 12, 2019 at 01:12:58PM +, Newbie2019 via Digitalmars-d-learn
wrote:
> https://run.dlang.io/is/s4cfiv
>
> onlineapp.d(23): Error: static variable A cannot be read at compile time
> onlineapp.d(23): Error: cannot implicitly convert expression 1 of type int
> to int*
>
> I see no
On Wednesday, 12 June 2019 at 13:53:09 UTC, H. S. Teoh wrote:
On Wed, Jun 12, 2019 at 01:12:58PM +, Newbie2019 via
Digitalmars-d-learn wrote:
Read:
https://wiki.dlang.org/User:Quickfur/Compile-time_vs._compile-time
T
Thanks for the tips.
I move the static array into local var then it
On Wednesday, 12 June 2019 at 10:06:39 UTC, Amex wrote:
When parsing an xml file I get #text for tagName on basically
every other element.
Those are the text nodes representing the whitespace between
elements.
`bar `
has: element Foo, text " ", element text.
On Wed, Jun 12, 2019 at 07:46:12PM +, Mek101 via Digitalmars-d-learn wrote:
[...]
> > public size_t indexOf(alias pred = "a == b", Range)(Range array)
> > {
> > alias predicate = unaryFun!pred;
> > for(size_t i = 0; i < array.length; i++)
> > if(predicate(array[i]))
> >
I didn't know it applied to templates other than lambdas.
Thank you for your explanation.
On Wednesday, 12 June 2019 at 14:09:08 UTC, Newbie2019 wrote:
On Wednesday, 12 June 2019 at 13:53:09 UTC, H. S. Teoh wrote:
On Wed, Jun 12, 2019 at 01:12:58PM +, Newbie2019 via
Digitalmars-d-learn wrote:
Read:
https://wiki.dlang.org/User:Quickfur/Compile-time_vs._compile-time
T
I'll try to be straight.
I have the following function:
public size_t indexOf(alias pred = "a == b", Range)(Range array)
{
alias predicate = unaryFun!pred;
for(size_t i = 0; i < array.length; i++)
if(predicate(array[i]))
return i;
On Wednesday, 12 June 2019 at 06:57:55 UTC, Robert M. Münch wrote:
If you use an associative array or a set, it's O(n) time and
O(n) space.
I don't see how this is the case. The AA itself has some
overhead too. So, the checking loop is O(n) but the AA lookups
not.
Hash table insertion and
13 matches
Mail list logo