February 10, 2015 Re: To write such an expressive code D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dennis Ritchie | On Tuesday, 10 February 2015 at 04:17:48 UTC, Dennis Ritchie wrote:
> I just need that code was only used features of the language without using library functions. You may only use the function sin().
Why is that?
Although D has a lot of language features, D tries to push functionality into the library as often as possible. This is better than having language features for everything, because you can then reimplement, tweak or replace said features by simply writing D code.
|
February 10, 2015 Re: To write such an expressive code D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir Panteleev | On Tuesday, 10 February 2015 at 08:12:00 UTC, Vladimir Panteleev wrote: > Why is that? Потому что я спорил с одним упёртым человеком, которому не нравится D, на этом форуме: http://www.cyberforum.ru/holywars/thread1367892-page13.html Он просил меня написать такую программу с использованием только возможностей языка и функции sin(). Because I was arguing with one quiet a stubborn person who does not like D, on this forum: http://www.cyberforum.ru/holywars/thread1367892-page13.html He asked me to write such a program using only the language features and functions sin(). |
February 10, 2015 Re: To write such an expressive code D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dennis Ritchie | On Tuesday, 10 February 2015 at 08:40:38 UTC, Dennis Ritchie wrote:
> On Tuesday, 10 February 2015 at 08:12:00 UTC, Vladimir Panteleev wrote:
>> Why is that?
>
> Потому что я спорил с одним упёртым человеком, которому не нравится D, на этом форуме:
> http://www.cyberforum.ru/holywars/thread1367892-page13.html
> Он просил меня написать такую программу с использованием только возможностей языка и функции sin().
>
> Because I was arguing with one quiet a stubborn person who does not like D, on this forum:
> http://www.cyberforum.ru/holywars/thread1367892-page13.html
> He asked me to write such a program using only the language features and functions sin().
How to win the holy language war:
1. Pick a feature that only one of the languages has
2. Pick a task that this feature solves neatly
3. Solve it using that feature
4. Forbid every other solution not involving the features that only your
preferred language has.
Done.
|
February 10, 2015 Re: To write such an expressive code D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dennis Ritchie | On Tuesday, 10 February 2015 at 08:40:38 UTC, Dennis Ritchie wrote:
> Because I was arguing with one quiet a stubborn person who does not like D, on this forum:
> http://www.cyberforum.ru/holywars/thread1367892-page13.html
> He asked me to write such a program using only the language features and functions sin().
If someone makes stupid demands like this one to justify his dislike for the language, such person is either deliberate troll or has strong enough prejudice no never like language anyway, arguments or not.
Language features don't magically appear from nowhere - those come at cost of extra code in compiler and/or runtime library making it very hard to use language with smaller runtime (D is actually guilty of that).
It is a common practice to treat standard language library as part of language. Both C and C++ include detailed spec on standard library in official language spec for example. As such making any distinction between two is impractical.
|
February 10, 2015 Re: To write such an expressive code D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dennis Ritchie Attachments: | On Tue, 10 Feb 2015 08:40:36 +0000, Dennis Ritchie wrote:
> On Tuesday, 10 February 2015 at 08:12:00 UTC, Vladimir Panteleev wrote:
>> Why is that?
>
> Потому что Ñ Ñпорил Ñ Ð¾Ð´Ð½Ð¸Ð¼ упёртым человеком, которому не нравитÑÑ D,
> на Ñтом форуме:
> http://www.cyberforum.ru/holywars/thread1367892-page13.html Он проÑил
> Ð¼ÐµÐ½Ñ Ð½Ð°Ð¿Ð¸Ñать такую программу Ñ Ð¸Ñпользованием только возможноÑтей Ñзыка
> и функции sin().
>
> Because I was arguing with one quiet a stubborn person who does not like D, on this forum: http://www.cyberforum.ru/holywars/thread1367892-page13.html He asked me to write such a program using only the language features and functions sin().
'cause he is a dumb asshead, that's it.
|
February 10, 2015 Re: To write such an expressive code D | ||||
---|---|---|---|---|
| ||||
Posted in reply to ketmar | Please help. import std.stdio; import std.stdio; void main() { /* return (a xor b xor c) */ int nobitxor(int a, int b, int c) { return (a + b + c == 2 || a + b + c == 0) ? 0 : 1; } int a, b, c; a = b = c = 0; foreach (i; 0 .. 8) { if (i > 3) a = 1; if (i == 2 || i == 3 || i == 6 || i == 7) b = 1; if (i % 2) c = 1; writeln(a, b, c, ' ', nobitxor(a, b, c)); a = b = c = 0; } } Output: 000 0 001 1 010 1 011 0 100 1 101 0 110 0 111 1 You need to function nobitxor(int a, int b, int c) not used bitwise/logical and mathematical operations. |
February 10, 2015 Re: To write such an expressive code D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dennis Ritchie | Dennis Ritchie:
> Please help.
This starts to look like homework :-)
Bye,
bearophile
|
February 10, 2015 Re: To write such an expressive code D | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Tuesday, 10 February 2015 at 11:33:54 UTC, bearophile wrote:
> Dennis Ritchie:
>
>> Please help.
>
> This starts to look like homework :-)
>
> Bye,
> bearophile
This is not homework - this is a war of code on C#/F# and D. I've been programming in D, my opponent on F#/C#.
|
February 10, 2015 Re: To write such an expressive code D | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile Attachments: | On Tue, 10 Feb 2015 11:33:54 +0000, bearophile wrote:
> Dennis Ritchie:
>
>> Please help.
>
> This starts to look like homework :-)
it's much worse: meaningless pseudocomparison of different languages for nothing.
|
February 10, 2015 Re: To write such an expressive code D | ||||
---|---|---|---|---|
| ||||
Posted in reply to ketmar | On Tuesday, 10 February 2015 at 11:41:20 UTC, ketmar wrote:
> On Tue, 10 Feb 2015 11:33:54 +0000, bearophile wrote:
>
>> Dennis Ritchie:
>>
>>> Please help.
>>
>> This starts to look like homework :-)
>
> it's much worse: meaningless pseudocomparison of different languages for
> nothing.
This task can be solved for D?
|
Copyright © 1999-2021 by the D Language Foundation