Skip to content

Commit 41c15f0

Browse files
author
Oren (electricessence)
committed
Reformat and contract improvments.
1 parent 1797721 commit 41c15f0

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

Triangular.cs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1-
/*!
1+
/*!
22
* @author electricessence / https://github.com/electricessence/
33
* Licensing: MIT https://github.com/electricessence/Genetic-Algorithm-Platform/blob/master/LICENSE.md
44
*/
55

6+
using Open.Collections;
67
using System;
78
using System.Collections.Generic;
89
using System.Linq;
910
using System.Threading;
10-
using Open.Collections;
1111

1212
namespace Open.Arithmetic
1313
{
1414

15-
public static class Triangular
16-
{
15+
public static class Triangular
16+
{
1717

18-
public static uint Forward(uint n)
19-
{
20-
return n * (n + 1) / 2;
21-
}
18+
public static uint Forward(uint n)
19+
{
20+
return n * (n + 1) / 2;
21+
}
2222

2323

24-
public static uint Reverse(uint n)
25-
{
26-
return (uint)(Math.Sqrt(8 * n + 1) - 1) / 2;
27-
}
24+
public static uint Reverse(uint n)
25+
{
26+
return (uint)(Math.Sqrt(8 * n + 1) - 1) / 2;
27+
}
2828

29-
public static class Disperse
30-
{
29+
public static class Disperse
30+
{
3131

32-
/**
32+
/**
3333
* Increases the number an element based on it's index.
3434
* @param source
3535
* @returns {Enumerable<T>}
3636
*/
37-
public static IEnumerable<T> Increasing<T>(IEnumerable<T> source)
38-
{
39-
int i = 0;
40-
return source.SelectMany(
41-
c => Enumerable.Repeat(c, Interlocked.Increment(ref i)));
42-
}
43-
44-
/**
37+
public static IEnumerable<T> Increasing<T>(IEnumerable<T> source)
38+
{
39+
int i = 0;
40+
return source.SelectMany(
41+
c => Enumerable.Repeat(c, Interlocked.Increment(ref i)));
42+
}
43+
44+
/**
4545
* Increases the count of each element for each index.
4646
* @param source
4747
* @returns {Enumerable<T>}
4848
*/
49-
public static IEnumerable<T> Decreasing<T>(IEnumerable<T> source)
50-
{
51-
var s = source.Memoize();
52-
int i = 0;
53-
return s.SelectMany(
54-
c => s.Take(Interlocked.Increment(ref i)));
55-
}
56-
}
57-
}
49+
public static IEnumerable<T> Decreasing<T>(IEnumerable<T> source)
50+
{
51+
var s = source.Memoize();
52+
int i = 0;
53+
return s.SelectMany(
54+
c => s.Take(Interlocked.Increment(ref i)));
55+
}
56+
}
57+
}
5858

5959
}

0 commit comments

Comments
 (0)