On Friday, 3 May 2024 at 05:11:28 UTC, Salih Dincer wrote:
..
Wouldn't it be great if there was a feature that worked at
runtime...
SDB@79
module m;
@safe:
private:
import std;
void main()
{
auto myTuple = tuple(1, 2, 3, [1, 3], 5);
int[] arrToSum;
foreach(int i, val; myTuple.
On Wednesday, 1 May 2024 at 14:15:19 UTC, Andrey Zherikov wrote:
Shorter and without allocations:
```d
import std.typecons : tuple;
import std.algorithm : sum, each;
auto sum(int i) => i;
void main()
{
auto t = tuple(1, 2, 3, [1, 3], 5);
int res=0;
t.each!(e => res += sum(e));
assert
On Friday, 26 April 2024 at 13:25:34 UTC, Salih Dincer wrote:
You have a 5-item data tuples as Tuple(1, 2, 3, [1, 3], 5) and
implement the sum (total = 15) with the least codes using the
sum() function of the language you are coding...
Let's start with D:
```d
import std.typecons : tuple;
im
On Friday, 26 April 2024 at 13:25:34 UTC, Salih Dincer wrote:
You have a 5-item data tuples as Tuple(1, 2, 3, [1, 3], 5) and
implement the sum (total = 15) with the least codes using the
sum() function of the language you are coding...
Nim:
```nim
import std/[math, typetraits, macros]
macro
On Friday, 26 April 2024 at 13:25:34 UTC, Salih Dincer wrote:
You have a 5-item data tuples as Tuple(1, 2, 3, [1, 3], 5) and
implement the sum (total = 15) with the least codes using the
sum() function of the language you are coding...
Let's start with D:
```d
import std.typecons : tuple;
im
On Saturday, 27 April 2024 at 15:36:40 UTC, Nick Treleaven wrote:
On Saturday, 27 April 2024 at 15:32:40 UTC, Nick Treleaven
wrote:
On Saturday, 27 April 2024 at 11:55:58 UTC, Basile B. wrote:
foreach const e in u do
if echo(is, e, T) do
result += e;
On Saturday, 27 April 2024 at 15:32:40 UTC, Nick Treleaven wrote:
On Saturday, 27 April 2024 at 11:55:58 UTC, Basile B. wrote:
foreach const e in u do
if echo(is, e, T) do
result += e;
static if (is(typeof(e) == int))
r += e;
Actually
On Saturday, 27 April 2024 at 11:55:58 UTC, Basile B. wrote:
Here's [STYX](https://gitlab.com/styx-lang/styx) solution:
function sum[T,U](U u): u32
I think you meant `: T`.
{
var T result;
foreach const e in u do
if echo(is, e, T) do
resul
On Friday, 26 April 2024 at 13:25:34 UTC, Salih Dincer wrote:
You have a 5-item data tuples as Tuple(1, 2, 3, [1, 3], 5) and
implement the sum (total = 15) with the least codes using the
sum() function of the language you are coding...
Let's start with D:
Here's [STYX](https://gitlab.com/st
On Friday, 26 April 2024 at 13:25:34 UTC, Salih Dincer wrote:
You have a 5-item data tuples as Tuple(1, 2, 3, [1, 3], 5) and
implement the sum (total = 15) with the least codes using the
sum() function of the language you are coding...
My Python solution (function named dosum to avoid collisio
On Friday, 26 April 2024 at 13:25:34 UTC, Salih Dincer wrote:
...
Very nice, for your first example I need to think a bit because
I'm bit rusty in C#, but I think it will not be as easier as D
version.
For the bonus part:
private static void Main(string[] args){
var a = (1,2,3,(1,3),5)
You have a 5-item data tuples as Tuple(1, 2, 3, [1, 3], 5) and
implement the sum (total = 15) with the least codes using the
sum() function of the language you are coding...
Let's start with D:
```d
import std.typecons : tuple;
import std.algorithm : sum;
void main()
{
auto t = tuple(1, 2,
12 matches
Mail list logo