On Wed, May 16, 2012 at 11:07 PM, H. S. Teoh wrote:
> On Wed, May 16, 2012 at 10:25:51PM -0500, Andrew Wiley wrote:
> > On Wed, May 16, 2012 at 11:03 AM, Regan Heath
> wrote:
> >
> > > On Wed, 16 May 2012 15:24:33 +0100, ref2401
> wrote:
> > >
> > > i have an array of ubytes. how can i convert
On Wed, May 16, 2012 at 10:25:51PM -0500, Andrew Wiley wrote:
> On Wed, May 16, 2012 at 11:03 AM, Regan Heath wrote:
>
> > On Wed, 16 May 2012 15:24:33 +0100, ref2401 wrote:
> >
> > i have an array of ubytes. how can i convert two adjacent ubytes from the
> >> array to an integer?
> >>
> >> pse
On Wednesday, May 16, 2012 20:58:02 H. S. Teoh wrote:
> Hindsight is always 20/20. I agree with you that it makes sense... but
> only after you've learned what it is. This does not help newcomers nor
> give them a good impression of D. We need to reduce the amount of stuff
> that only makes sense
On Wed, May 16, 2012 at 08:37:08PM -0700, Jonathan M Davis wrote:
> On Tuesday, May 15, 2012 09:48:23 H. S. Teoh wrote:
> > On Tue, May 15, 2012 at 07:47:24PM +0400, Dmitry Olshansky wrote:
> > > On 15.05.2012 19:32, H. S. Teoh wrote:
> > > >On Tue, May 15, 2012 at 05:14:15PM +0200, ref2401 wrote:
On Tuesday, May 15, 2012 09:48:23 H. S. Teoh wrote:
> On Tue, May 15, 2012 at 07:47:24PM +0400, Dmitry Olshansky wrote:
> > On 15.05.2012 19:32, H. S. Teoh wrote:
> > >On Tue, May 15, 2012 at 05:14:15PM +0200, ref2401 wrote:
> > >>general question:
> > >>-std.file,
> > >
> > >std.file is badly name
On Wed, May 16, 2012 at 11:03 AM, Regan Heath wrote:
> On Wed, 16 May 2012 15:24:33 +0100, ref2401 wrote:
>
> i have an array of ubytes. how can i convert two adjacent ubytes from the
>> array to an integer?
>>
>> pseudocode example:
>> ubyte[5] array = createArray();
>> int value = array[2..3]
On Thursday, May 17, 2012 02:32:55 Robert DaSilva wrote:
> On Wednesday, 16 May 2012 at 18:47:55 UTC, Jonathan M Davis wrote:
> > As long as you're going from big endian to little endian,
> > std.bitmanip.bigEndianToNative will do the conversion fairly
> > easily, but if
> > they're in little endia
On Wednesday, 16 May 2012 at 18:47:55 UTC, Jonathan M Davis wrote:
As long as you're going from big endian to little endian,
std.bitmanip.bigEndianToNative will do the conversion fairly
easily, but if
they're in little endian, then the nasty casting is the way to
go.
- Jonathan M Davis
Exce
On Wednesday, 16 May 2012 at 20:50:55 UTC, Nick Sabalausky wrote:
I was initially open to the idea I may have just misunderstood
something, but I'm becoming more and more convinced that the
current "foreach over an implicit copy" behavior is indeed a
bad idea.
I'd love to see Andrei weigh in
Actually, I think I'm going to move this over to "digitalmars.D". Seems a
more appropriate place at this point.
On Wednesday, May 16, 2012 12:05:02 H. S. Teoh wrote:
> It would be nice if there was an easy way of switching allocators, so
> that you can, for example, indicate that all allocations done inside a
> particular function should use malloc/free (including, say, AA's,
> arrays, etc.), and have the ru
"Jonathan M Davis" wrote in message
news:mailman.828.1337154007.24740.digitalmars-d-le...@puremagic.com...
> On Wednesday, May 16, 2012 03:29:23 Nick Sabalausky wrote:
>> "Jonathan M Davis" wrote in message
>> news:mailman.826.1337151940.24740.digitalmars-d-le...@puremagic.com...
>>
>> > No. Tha
Original code in this thread run on my pc in ~400ms.
With my skipping method it takes just ~10ms.
But I think there're more improvement.
However using CTFE I guess time goes down to 0 ;)
On Wednesday, 16 May 2012 at 19:50:45 UTC, Era Scarecrow wrote:
On Wednesday, 16 May 2012 at 13:10:06 UTC,
On Wednesday, 16 May 2012 at 13:10:06 UTC, Tiberiu Gal wrote:
The correct answer is 55
Your versions of isCircularPrime just truncates the number (
this is actually useful in a next problem though; )
Hmm glancing at the original source I see what you mean. A
slight modification to fill prim
On 05/16/2012 07:14 AM, Tiberiu Gal wrote:
> "You'll skip 70% of checks..."
> that's true for the Circular check ... but in the whole app, the most
> time is spent finding primes.
A number that cannot be circular prime need not be checked whether
regular prime.
Ali
--
D Programming Language T
On Wed, May 16, 2012 at 02:20:47PM -0400, Jonathan M Davis wrote:
> On Wednesday, May 16, 2012 13:52:12 Steven Schveighoffer wrote:
> > Where the GC gets into trouble is with allocation of large chunks of
> > data.
> >
> > If the data 'contains pointers', it creates a very good chance that
> > the
On Wednesday, May 16, 2012 17:03:44 Regan Heath wrote:
> On Wed, 16 May 2012 15:24:33 +0100, ref2401 wrote:
> > i have an array of ubytes. how can i convert two adjacent ubytes from
> > the array to an integer?
> >
> > pseudocode example:
> > ubyte[5] array = createArray();
> > int value = array[
On Wednesday, May 16, 2012 13:52:12 Steven Schveighoffer wrote:
> Where the GC gets into trouble is with allocation of large chunks of data.
>
> If the data 'contains pointers', it creates a very good chance that the
> data keeps some unknown number of blocks from being deallocated.
>
> And just
On 16/05/2012 09:24, Jacob Carlborg wrote:
On 2012-05-16 09:00, Jonathan M Davis wrote:
Probably true. But also, if you're talking about a const pointer to a
mutable
value, the constness of the pointer is actually irrelevant to the
caller. The
pointer will be copied when the function is called,
On Wed, 16 May 2012 12:52:33 -0400, Jonathan M Davis
wrote:
On Wednesday, May 16, 2012 11:51:59 Steven Schveighoffer wrote:
Well, the D GC is conservative, and will always be at least partly
conservative. So freeing memory manually is not really a crime.
The idea with a GC is that it's sup
On Wednesday, May 16, 2012 11:51:59 Steven Schveighoffer wrote:
> Well, the D GC is conservative, and will always be at least partly
> conservative. So freeing memory manually is not really a crime.
The idea with a GC is that it's supposed to manage the memory allocated
through it. So, if you're
On Wed, 16 May 2012 15:24:33 +0100, ref2401 wrote:
i have an array of ubytes. how can i convert two adjacent ubytes from
the array to an integer?
pseudocode example:
ubyte[5] array = createArray();
int value = array[2..3];
is there any 'memcpy' method or something else to do this?
You don
Hmm... It's probably confused by multiple threads. You can try to
copy the source for dll_process_attach and insert debugging code
there.
On Tue, 15 May 2012 05:43:45 -0400, Jonathan M Davis
wrote:
On Tuesday, May 15, 2012 11:26:49 Namespace wrote:
On Tuesday, 15 May 2012 at 09:23:51 UTC, Kagamin wrote:
> Difference with what?
> new is a safe feature: it allocates in the GC heap
That's what i mean. So i have to delete it your
On Wednesday, 16 May 2012 at 11:12:19 UTC, Stephen Jones wrote:
Cain: My understanding is that D is based on "no proper ways of
doing things" just get the job done. The use of properties when
you can use public access baffles me. So long as you are
I suppose "proper way of doing things" isn't
The number, 197, is called a circular prime because all rotations
of the digits: 197, 971, and 719, are themselves prime.
There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17,
31, 37, 71, 73, 79, and 97.
How many circular primes are there below one million?
=
i have an array of ubytes. how can i convert two adjacent ubytes
from the array to an integer?
pseudocode example:
ubyte[5] array = createArray();
int value = array[2..3];
is there any 'memcpy' method or something else to do this?
"You'll skip 70% of checks..."
that's true for the Circular check ... but in the whole app, the
most time is spent finding primes.
On Wednesday, 16 May 2012 at 14:01:19 UTC, Andrea Fontana wrote:
Not that big gain?
If you check for circulars numbers from 0 to 1.000.000 you can
skip interval
Probabily i miss the point. Are you looking for prime & circular
primes or for circular primes only?
On Wednesday, 16 May 2012 at 14:14:15 UTC, Tiberiu Gal wrote:
"You'll skip 70% of checks..."
that's true for the Circular check ... but in the whole app,
the most time is spent finding primes.
On Wednesday, 16 May 2012 at 09:46:06 UTC, Dmitry Olshansky wrote:
On 16.05.2012 13:26, Tiberiu Gal wrote:
hi
many claim their code solves the problem in order of ms (
c/pascal/haskell code)
my D code takes ~1.5 seconds.
Can it be made faster ( without pointers )?
it runs the same with or with
Not that big gain?
If you check for circulars numbers from 0 to 1.000.000 you can
skip intervals from 200.000 to 299.999, from 400.000 to 699.999
and from 800.000 to 899.999 (and other sub-intervals, of course).
You'll skip 70% of checks...
On Wednesday, 16 May 2012 at 13:14:37 UTC, Tiberiu
Good point there, unfortunately it's not that big a gain in this
particular instance.
thank you
On Wednesday, 16 May 2012 at 12:46:07 UTC, Andrea Fontana wrote:
What about some logic optimizations?
F.E. if number contains one of these digit 0,2,4,6,8,5 is not
circular of course ..
On Wedn
The correct answer is 55
Your versions of isCircularPrime just truncates the number ( this
is actually useful in a next problem though; )
prime_walks is a nice and efficient way to find primes ... and
not a bit n00bfriendly.
I'm not posting it anywhere, I'm just learning and having fun.
On
What about some logic optimizations?
F.E. if number contains one of these digit 0,2,4,6,8,5 is not
circular of course ..
On Wednesday, 16 May 2012 at 09:26:45 UTC, Tiberiu Gal wrote:
hi
many claim their code solves the problem in order of ms (
c/pascal/haskell code)
my D code takes ~1.5
>Am 16.05.2012 13:12, schrieb Stephen Jones:
just throw aways your sensless void pointer or whatever idea - create a
base interface or better base-class - everything else is just damn wrong
btw: all oop widget sets for c++, java or else are haveing a widget base
class that works like people t
On Wednesday, 16 May 2012 at 11:12:19 UTC, Stephen Jones wrote:
Ali your post above, and T your post in the other forum
(Simpsons bit) is sort of what I was after. I tried both
interface and abstract class but not outright super class. The
problem I have with the solution is the same problem I
On Wednesday, 16 May 2012 at 02:55:41 UTC, H. S. Teoh wrote:
On Wed, May 16, 2012 at 04:01:23AM +0200, Stephen Jones wrote:
[...]
Using Object gives exactly the same problem as the Object super
class does not have vcount variable. Casting is not a solution
because the reason for throwing differe
On Wednesday, 16 May 2012 at 09:46:06 UTC, Dmitry Olshansky wrote:
On 16.05.2012 13:26, Tiberiu Gal wrote:
foreach(i; 2 .. Max) {
//writefln("is %s prime ? %s ", i, i.isPrime);
if( i.isPrime && i.isCircularPrime) {
cnt++;
Curiously i've just posted a sample (as part of another topic)
that
On 16.05.2012 13:26, Tiberiu Gal wrote:
hi
many claim their code solves the problem in order of ms (
c/pascal/haskell code)
my D code takes ~1.5 seconds.
Can it be made faster ( without pointers )?
it runs the same with or without caching the primes, and most of the
time it spends finding prime
hi
many claim their code solves the problem in order of ms (
c/pascal/haskell code)
my D code takes ~1.5 seconds.
Can it be made faster ( without pointers )?
it runs the same with or without caching the primes, and most of
the time it spends finding primes; isCircularPrime can be
optimized
On 2012-05-16 09:00, Jonathan M Davis wrote:
Probably true. But also, if you're talking about a const pointer to a mutable
value, the constness of the pointer is actually irrelevant to the caller. The
pointer will be copied when the function is called, so it doesn't matter on
whit whether the po
On Wednesday, May 16, 2012 09:48:20 Era Scarecrow wrote:
> Hmmm...
> [quote]
> void main()
> {
> Foo foo;
> foreach(val; foo)
> writeln(foo.val, " ", val);
> }
> [/quote]
>
> Indeed... he is using foo.val isn't he? Instead he should just
> use 'val' by itself.
Well, there's n
On 5/16/12 9:24 AM, Stephen Jones wrote:
Ary: I seem to remember playing around with a Simpsons extending program
in Java that did this; you could throw all the different Simpsons into a
single Array because they extended "Simpson", and you could walk through
the array and each would call their o
On Wednesday, 16 May 2012 at 07:41:14 UTC, Jonathan M Davis wrote:
void main()
{
prime_walk pw;
pw.cap = 100;
foreach(i; pw)
writefln("%s %s", i, pw.position);
}
You'd see that pw.postion is always printed as 2, just like
Nick's foo.val
always prints as 0.
Hmmm...
[quote
On Wednesday, May 16, 2012 09:24:23 Era Scarecrow wrote:
> On Wednesday, 16 May 2012 at 07:04:09 UTC, Jonathan M Davis wrote:
> > that assertion would pass, but it doesn't, and it shouldn't. If
> > your range was a reference type (e.g. if it were a class or it
> > was like the ranges in std.stdio w
On Wednesday, May 16, 2012 03:29:23 Nick Sabalausky wrote:
> "Jonathan M Davis" wrote in message
> news:mailman.826.1337151940.24740.digitalmars-d-le...@puremagic.com...
>
> > No. That's expected. Your range is a value type, so it got copied when you
> > used it with foreach.
>
> But foreach isn
"Jonathan M Davis" wrote in message
news:mailman.826.1337151940.24740.digitalmars-d-le...@puremagic.com...
>
> No. That's expected. Your range is a value type, so it got copied when you
> used it with foreach.
But foreach isn't a function, it's a flow-control statement.
On Wednesday, 16 May 2012 at 07:04:09 UTC, Jonathan M Davis wrote:
that assertion would pass, but it doesn't, and it shouldn't. If
your range was a reference type (e.g. if it were a class or it
was like the ranges in std.stdio which deal with I/O), then
using it with foreach would consume it, b
On 5/16/2012 10:15 AM, WhatMeWorry wrote:
I'm just going start from scratch. However, this might be a real
beginner question, but when I go to the
ttp://svn.dsource.org/projects/derelict/branches/Derelict2 link, I see
Revision 630: /branches/Derelict2
..
DerelictAL/
DerelictAllegro/
DerelictFM
On Wednesday, May 16, 2012 09:15:06 bearophile wrote:
> Nick Sabalausky:
> > It seems that foreach is iterating over an implicit copy of
> > 'foo' instead of
> > 'foo' itself. Is this correct behavior, or a DMD bug?
>
> This program prints "[11, 21, 31]" so for fixed-size arrays (that
> are values
Nick Sabalausky:
It seems that foreach is iterating over an implicit copy of
'foo' instead of
'foo' itself. Is this correct behavior, or a DMD bug?
This program prints "[11, 21, 31]" so for fixed-size arrays (that
are values as much as structs) it doesn't perform a copy:
import std.stdio;
v
On Wednesday, May 16, 2012 02:43:19 Nick Sabalausky wrote:
> This code:
>
> --
> import std.stdio;
>
> struct Foo
> {
> int val;
>
> @property bool empty() {
> return val >= 5;
> }
>
> @property int front() {
> return val;
On Wednesday, May 16, 2012 08:50:27 Jacob Carlborg wrote:
> On 2012-05-16 07:35, Simen Kjaeraas wrote:
> > That depends. Will the contents be modified?
>
> I have no idea. I'm working on a tool for automatically translating C
> headers. I was thinking since I don't know, I better not add any
> pro
53 matches
Mail list logo