On 2015-02-11 at 01:56, bearophile wrote:
Alternative solution closer to the F# code:
import std.stdio, std.algorithm, std.typecons;
int f(T)(T t) if (isTuple!T) {
return t.predSwitch(
tuple(0, 0, 0), 0,
tuple(0, 1, 1), 0,
tuple(1, 0, 1), 0,
tuple(1, 1,
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
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
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
Он просил меня написать такую программу с использованием
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, на этом форуме:
On Tue, 10 Feb 2015 08:40:36 +, Dennis Ritchie wrote:
On Tuesday, 10 February 2015 at 08:12:00 UTC, Vladimir Panteleev wrote:
Why is that?
ÐоÑÐ¾Ð¼Ñ ÑÑо Ñ ÑпоÑил Ñ Ð¾Ð´Ð½Ð¸Ð¼ ÑпÑÑÑÑм
Ñеловеком, коÑоÑÐ¾Ð¼Ñ Ð½Ðµ нÑавиÑÑÑ D,
на ÑÑом
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#.
On Tue, 10 Feb 2015 11:33:54 +, bearophile wrote:
Dennis Ritchie:
Please help.
This starts to look like homework :-)
it's much worse: meaningless pseudocomparison of different languages for
nothing.
signature.asc
Description: PGP signature
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;
Dennis Ritchie:
Please help.
This starts to look like homework :-)
Bye,
bearophile
On Tuesday, 10 February 2015 at 11:41:20 UTC, ketmar wrote:
On Tue, 10 Feb 2015 11:33:54 +, 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
F#:
let f = function
| 0 , 0 , 0 - 0
| 0 , 1 , 1 - 0
| 1 , 0 , 1 - 0
| 1 , 1 , 0 - 0
| _ - 1
for a in 0..1 do
for b in 0..1 do
for c in 0..1 do
printfn %i xor %i xor %i = %i a b c (f (a, b, c))
Output:
0 xor 0 xor 0 = 0
0 xor 0 xor 1 = 1
0
Dennis Ritchie:
Output:
0 xor 0 xor 0 = 0
0 xor 0 xor 1 = 1
0 xor 1 xor 0 = 1
0 xor 1 xor 1 = 0
1 xor 0 xor 0 = 1
1 xor 0 xor 1 = 0
1 xor 1 xor 0 = 0
1 xor 1 xor 1 = 1
This man again took advantage of the fact that in D there is no
such operation - (analog switch).
A natural solution in D:
On Wednesday, 11 February 2015 at 00:56:03 UTC, bearophile wrote:
Dennis Ritchie:
Output:
0 xor 0 xor 0 = 0
0 xor 0 xor 1 = 1
0 xor 1 xor 0 = 1
0 xor 1 xor 1 = 0
1 xor 0 xor 0 = 1
1 xor 0 xor 1 = 0
1 xor 1 xor 0 = 0
1 xor 1 xor 1 = 1
This man again took advantage of the fact that in D there
On 02/09/2015 08:17 PM, Dennis Ritchie wrote:
Ali, and you can write it without using the function iota() and map?
No because the a..b syntax is not a D language construct that we can use
anywhere that it makes sense. It only works as number ranges inside
foreach loops, when indexing slices,
On Monday, 9 February 2015 at 20:16:45 UTC, Ali Çehreli wrote:
Yes, but apparently D's default precision for output is less
than F#'s so how about the following? :p
%(%.15g\n%).writefln(iota(0, PI/2, PI/2/9).map!sin);
Just for demonstration, I would not write anything like that
but the
On Tuesday, 10 February 2015 at 06:17:17 UTC, Ali Çehreli wrote:
On 02/09/2015 08:17 PM, Dennis Ritchie wrote:
Ali, and you can write it without using the function iota()
and map?
No because the a..b syntax is not a D language construct that
we can use anywhere that it makes sense. It only
On Monday, 9 February 2015 at 20:03:00 UTC, Vladimir Panteleev
wrote:
On Monday, 9 February 2015 at 19:57:23 UTC, Ali Çehreli wrote:
writefln(%(%.15g\n%), sins);
In 2.067, you can write:
iota(0, PI/2, PI/2/9).map!sin.each!writeln;
March 1!
On Monday, 9 February 2015 at 19:40:42 UTC, Dennis Ritchie wrote:
Good evening.
Is it possible to D something to replace the container on the
F#, which displays the values of the sine from 0 to 90 degrees
with an interval of 10 degrees:
let pi = Math.PI
let sins = [for x in 0.0..pi / 2.0 /
On 02/09/2015 11:45 AM, Tobias Pankrath wrote:
iota(0, 91, 10).map!sin.writeln
or something like that.
Yes: :)
import std.math;
import std.stdio;
import std.range;
import std.algorithm;
void main()
{
const beg = 0.0L;
const interval = PI_2 / 9;
const end = PI_2 + interval;
On 02/09/2015 12:05 PM, Dennis Ritchie wrote:
On Monday, 9 February 2015 at 20:03:00 UTC, Vladimir Panteleev wrote:
On Monday, 9 February 2015 at 19:57:23 UTC, Ali Çehreli wrote:
writefln(%(%.15g\n%), sins);
In 2.067, you can write:
iota(0, PI/2, PI/2/9).map!sin.each!writeln;
March 1!
Good evening.
Is it possible to D something to replace the container on the F#,
which displays the values of the sine from 0 to 90 degrees with
an interval of 10 degrees:
let pi = Math.PI
let sins = [for x in 0.0..pi / 2.0 / 9.0..pi / 2.0 - sin x]
sins.Dump()
Output:
0
0,17364817766693
Thank you, Tobias Pankrath and Ali Çehreli.
On Monday, 9 February 2015 at 19:57:23 UTC, Ali Çehreli wrote:
writefln(%(%.15g\n%), sins);
In 2.067, you can write:
iota(0, PI/2, PI/2/9).map!sin.each!writeln;
24 matches
Mail list logo