On Sunday, 14 November 2021 at 04:29:53 UTC, forkit wrote:
On Saturday, 13 November 2021 at 23:02:15 UTC, pascal111 wrote:
I touch that D is big language, it's not small like standard
C. This will cost me much studying, so I think I need slow
down and learn it step by step.
Yes. C is so
On Saturday, 13 November 2021 at 23:02:15 UTC, pascal111 wrote:
I touch that D is big language, it's not small like standard C.
This will cost me much studying, so I think I need slow down
and learn it step by step.
Yes. C is so much smaller, and thus simpler (till you wanna do
something
On Thursday, 11 November 2021 at 22:30:12 UTC, forkit wrote:
On Tuesday, 2 November 2021 at 23:45:39 UTC, pascal111 wrote:
[...]
ok.. for a more on topic response..
First: Please name your variables sensibly:
char negativity, even; // grrr!!!
char answer1, answer2; // makes so
On Thursday, 11 November 2021 at 19:34:42 UTC, Stanislav Blinov
wrote:
Original C code from the first post can only fail on I/O, which
is arguably out of your control. And the meat of it amounts to
10 conditional stores. Your implementations, in both C and D,
are a very, very far distance
On Friday, 12 November 2021 at 01:05:15 UTC, Stanislav Blinov
wrote:
On Thursday, 11 November 2021 at 22:10:04 UTC, forkit wrote:
It's called 'staged learning'.
Staged learning is the only way for humans to learn, due to
the limitations of the human cognitive system. Specifically,
the way
On Friday, 12 November 2021 at 01:05:15 UTC, Stanislav Blinov
wrote:
On Thursday, 11 November 2021 at 22:10:04 UTC, forkit wrote:
It's called 'staged learning'.
Staged learning is the only way for humans to learn, due to
the limitations of the human cognitive system. Specifically,
the way
On Thursday, 11 November 2021 at 22:10:04 UTC, forkit wrote:
It's called 'staged learning'.
Staged learning is the only way for humans to learn, due to the
limitations of the human cognitive system. Specifically, the
way short-term memory and long-term memory facilitate learning.
Those who
On Thursday, 11 November 2021 at 23:41:48 UTC, kdevel wrote:
On Thursday, 11 November 2021 at 22:30:12 UTC, forkit wrote:
[...]
for(int i = 0; i < sizeof(numbers) / sizeof(int); ++i) //
is so much safer - in C style
I made it even safer:
for (int i = 0; i < sizeof numbers / sizeof
On Thursday, 11 November 2021 at 21:56:19 UTC, Ali Çehreli wrote:
On 11/11/21 11:34 AM, Stanislav Blinov wrote:
> Pessimization, though, is laughably easy, and
> should be avoided at all costs.
I am not passionate about this topic at all and I am here
mostly because I have fun in this forum.
On Thursday, 11 November 2021 at 22:30:12 UTC, forkit wrote:
[...]
for(int i = 0; i < sizeof(numbers) / sizeof(int); ++i) //
is so much safer - in C style
I made it even safer:
for (int i = 0; i < sizeof numbers / sizeof *numbers; ++i)
Maybe the type of numbers is changed in the
On Tuesday, 2 November 2021 at 23:45:39 UTC, pascal111 wrote:
Next code originally was a classic C code I've written, it's
pure vertical thinking, now, I converted it successfully to D
code, but I think I made no much changes to make it has more
horizontal thinking style that it seems D
On Thursday, 11 November 2021 at 21:13:03 UTC, Stanislav Blinov
wrote:
On Thursday, 11 November 2021 at 00:11:07 UTC, H. S. Teoh wrote:
It depends on what you're doing. In the OP's example, yeah
worrying about allocations is totally blowing things out of
proportions.
But that's the thing.
On 11/11/21 11:34 AM, Stanislav Blinov wrote:
> Pessimization, though, is laughably easy, and
> should be avoided at all costs.
I am not passionate about this topic at all and I am here mostly because
I have fun in this forum. So, I am fine in general.
However, I don't agree that
On Thursday, 11 November 2021 at 00:11:07 UTC, H. S. Teoh wrote:
It depends on what you're doing. In the OP's example, yeah
worrying about allocations is totally blowing things out of
proportions.
But that's the thing. How would one ever learn to know where that
dividing line is if all the
On Wednesday, 10 November 2021 at 23:15:09 UTC, forkit wrote:
On Wednesday, 10 November 2021 at 22:17:48 UTC, russhy wrote:
On Wednesday, 10 November 2021 at 06:47:32 UTC, forkit wrote:
btw. My pc has 24GB of main memory, and my CPU 8MB L3 cache.
So I really don't give a damn about allocations
On Thu, Nov 11, 2021 at 01:09:26AM +, forkit via Digitalmars-d-learn wrote:
> On Thursday, 11 November 2021 at 00:11:07 UTC, H. S. Teoh wrote:
> > On Wed, Nov 10, 2021 at 11:39:40PM +, forkit via Digitalmars-d-learn
> > wrote: [...]
> > > I still remember compiling code on my 286x86 ...
On Thursday, 11 November 2021 at 00:11:07 UTC, H. S. Teoh wrote:
On Wed, Nov 10, 2021 at 11:39:40PM +, forkit via
Digitalmars-d-learn wrote: [...]
I still remember compiling code on my 286x86 ... talk about
low memory..whoaaah.
...
But if you're in a time-constrained inner loop, you do
On Wed, Nov 10, 2021 at 11:39:40PM +, forkit via Digitalmars-d-learn wrote:
[...]
> I still remember compiling code on my 286x86 ... talk about low
> memory..whoaaah.
That's nothing! ;-)
When I was a kid, I programmed a computer that had only 48K of RAM
(that's 48 *kilo*bytes, not
On Wed, Nov 10, 2021 at 03:13:08PM -0800, Ali Çehreli via Digitalmars-d-learn
wrote:
> On 11/10/21 3:05 PM, H. S. Teoh wrote:
>
> > I cannot compile even simple programs on a low-memory system because
> > the compiler runs out of memory
>
> Did the -lowmem switch help in some cases?
On my
On Wednesday, 10 November 2021 at 23:05:06 UTC, H. S. Teoh wrote:
On Wed, Nov 10, 2021 at 10:17:48PM +, russhy via
Digitalmars-d-learn wrote:
On Wednesday, 10 November 2021 at 06:47:32 UTC, forkit wrote:
> btw. My pc has 24GB of main memory, and my CPU 8MB L3 cache.
> So I really don't
On Wednesday, 10 November 2021 at 22:17:48 UTC, russhy wrote:
On Wednesday, 10 November 2021 at 06:47:32 UTC, forkit wrote:
btw. My pc has 24GB of main memory, and my CPU 8MB L3 cache.
So I really don't give a damn about allocations .. not one
little bit ;-)
Having the right mindset helps
On 11/10/21 3:05 PM, H. S. Teoh wrote:
> I cannot compile
> even simple programs on a low-memory system because the compiler runs
> out of memory
Did the -lowmem switch help in some cases?
Is -betterC any better? ;)
Ali
On Wed, Nov 10, 2021 at 10:17:48PM +, russhy via Digitalmars-d-learn wrote:
> On Wednesday, 10 November 2021 at 06:47:32 UTC, forkit wrote:
> > btw. My pc has 24GB of main memory, and my CPU 8MB L3 cache. So I
> > really don't give a damn about allocations .. not one little bit ;-)
>
> It's
On Wednesday, 10 November 2021 at 06:47:32 UTC, forkit wrote:
btw. My pc has 24GB of main memory, and my CPU 8MB L3 cache. So
I really don't give a damn about allocations .. not one little
bit ;-)
It's not a good mindset to have
Give room for the unexpected, don't burn all of your options
On Wednesday, 10 November 2021 at 06:47:32 UTC, forkit wrote:
btw. My pc has 24GB of main memory, and my CPU 8MB L3 cache. So
I really don't give a damn about allocations .. not one little
bit ;-)
That's not the point. The point is the program is doing
unnecessary non-trivial work while
On Wednesday, 10 November 2021 at 04:54:58 UTC, Stanislav Blinov
wrote:
On Tuesday, 9 November 2021 at 11:03:09 UTC, forkit wrote:
They both produce exactly the same output.
But do vastly different things.
But I tell ya.. the cognitive load .. well.. it increased
dramatically ;-)
Of
On Wednesday, 10 November 2021 at 04:54:58 UTC, Stanislav Blinov
wrote:
On Tuesday, 9 November 2021 at 11:03:09 UTC, forkit wrote:
They both produce exactly the same output.
But do vastly different things.
But I tell ya.. the cognitive load .. well.. it increased
dramatically ;-)
Of
On Tuesday, 9 November 2021 at 11:03:09 UTC, forkit wrote:
They both produce exactly the same output.
But do vastly different things.
But I tell ya.. the cognitive load .. well.. it increased
dramatically ;-)
Of course it did. Cuz you overthunk it. Dramatically.
Your D version allocates
On Monday, 8 November 2021 at 12:04:26 UTC, forkit wrote:
On Tuesday, 2 November 2021 at 23:45:39 UTC, pascal111 wrote:
Next code originally was a classic C code I've written, it's
pure vertical thinking, now, I converted it successfully to D
code, but I think I made no much changes to make it
On Monday, 8 November 2021 at 12:04:26 UTC, forkit wrote:
case 'o' :
result = result.filter!(a => (a % 2 == 1)).array;
oops.
case 'o' :
result = result.filter!(a => (a % 2 != 0)).array;
On Tuesday, 2 November 2021 at 23:45:39 UTC, pascal111 wrote:
Next code originally was a classic C code I've written, it's
pure vertical thinking, now, I converted it successfully to D
code, but I think I made no much changes to make it has more
horizontal thinking style that it seems D
On Saturday, 6 November 2021 at 13:48:59 UTC, jfondren wrote:
On Saturday, 6 November 2021 at 13:27:55 UTC, kdevel wrote:
On Thursday, 4 November 2021 at 00:53:11 UTC, jfondren wrote:
On Wednesday, 3 November 2021 at 20:36:08 UTC, russhy wrote:
Keeping things simple helps debugging!
As
On Saturday, 6 November 2021 at 13:27:55 UTC, kdevel wrote:
On Thursday, 4 November 2021 at 00:53:11 UTC, jfondren wrote:
On Wednesday, 3 November 2021 at 20:36:08 UTC, russhy wrote:
Keeping things simple helps debugging!
I'd still have to run your program to be sure of its simple
logic,
On Thursday, 4 November 2021 at 00:53:11 UTC, jfondren wrote:
On Wednesday, 3 November 2021 at 20:36:08 UTC, russhy wrote:
Keeping things simple helps debugging!
I'd still have to run your program to be sure of its simple
logic, though. The real star d feature that would help with
debugging
On Wednesday, 3 November 2021 at 20:36:08 UTC, russhy wrote:
Keeping things simple helps debugging!
I'd still have to run your program to be sure of its simple
logic, though. The real star d feature that would help with
debugging is unittest:
```d
enum sign { negatives = 'n', positives =
On 11/3/21 11:41 AM, Stanislav Blinov wrote:
> And Ali... associative arrays? For this? What are you trying to teach
> the good beginner here? :D
Obviously, we're all enjoying this thread but once the OP made it clear
that they wanted a C-like solution, I took some liberty with alternative
On Wednesday, 3 November 2021 at 20:36:08 UTC, russhy wrote:
I don't understand why you guys offer OP such
complicate/bloated examples, it'll only make things confusing
and slow down compilation time with templates and imports, this
is not needed at all
I don't like complicated things
The code "as is" is perfectly fine
I don't understand why you guys offer OP such complicate/bloated
examples, it'll only make things confusing and slow down
compilation time with templates and imports, this is not needed
at all
One change, use .length property instead of the hardcoded
On Wednesday, 3 November 2021 at 00:50:51 UTC, Siarhei Siamashka
wrote:
!text.join("\n").writeln;
Ahem... You've turned a program that does not allocate to a
program that allocates who knows how much memory?
And Ali... associative arrays? For this? What are you trying to
teach the
On Wednesday, 3 November 2021 at 00:57:38 UTC, Ali Çehreli wrote:
On 11/2/21 5:50 PM, Siarhei Siamashka wrote:
Your code can be changed to something like this:
And I over-engineered it. :)
import std.stdio;
import std.algorithm;
import std.range;
import std.exception;
import std.format;
.
.
On Wednesday, 3 November 2021 at 00:50:51 UTC, Siarhei Siamashka
wrote:
On Tuesday, 2 November 2021 at 23:45:39 UTC, pascal111 wrote:
By "vertical" vs. "horizontal" thinking, do you mean imperative
vs. functional style?
On 11/2/21 5:50 PM, Siarhei Siamashka wrote:
Your code can be changed to
something like this:
And I over-engineered it. :)
import std.stdio;
import std.algorithm;
import std.range;
import std.exception;
import std.format;
// A readable name; corresponds to C's typedef
alias FilterFunction =
On Wednesday, 3 November 2021 at 00:50:51 UTC, Siarhei Siamashka
wrote:
On Tuesday, 2 November 2021 at 23:45:39 UTC, pascal111 wrote:
It's supported in many modern programming languages and it's
not a unique feature of the D language alone. Your code can be
changed to something like this:
On Tuesday, 2 November 2021 at 23:45:39 UTC, pascal111 wrote:
Next code originally was a classic C code I've written, it's
pure vertical thinking, now, I converted it successfully to D
code, but I think I made no much changes to make it has more
horizontal thinking style that it seems D
Next code originally was a classic C code I've written, it's pure
vertical thinking, now, I converted it successfully to D code,
but I think I made no much changes to make it has more horizontal
thinking style that it seems D programmers care in horizontal
thinking style. Is there any
45 matches
Mail list logo