Skip to content

Commit

Permalink
Autoformatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Timwi committed Jun 11, 2021
1 parent bcf4cc4 commit 3e02c9b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Src/Runic/Pointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private List<object> PopStack()

public void PopDiscardStack()
{
if(substacks.Count > 0)
if (substacks.Count > 0)
{
List<object> o = substacks[substacks.Count - 1];
substacks.RemoveAt(substacks.Count - 1);
Expand Down
11 changes: 5 additions & 6 deletions Src/Runic/Runes/RuneConcatenate.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
using EsotericIDE.Runic.Math;
using System;
using System.Text;
using EsotericIDE.Runic.Math;

namespace EsotericIDE.Runic.Runes
{
public class RuneConcatenate : IExecutableRune
{
public bool Execute(Pointer pointer, IRunicContext context)
{
if(context.GetModifier(pointer.position.x,pointer.position.y) == '͍')
if (context.GetModifier(pointer.position.x, pointer.position.y) == '͍')
{
string result = "";
object o = pointer.Pop();
while(o is char && pointer.GetStackSize() > 0)
while (o is char && pointer.GetStackSize() > 0)
{
result += (char)o;
result += (char) o;
o = pointer.Pop();
}
if(o is char) result += (char)o;
if (o is char) result += (char) o;
else pointer.Push(o);
result = result.Reverse();
pointer.Push(result);
Expand Down
41 changes: 21 additions & 20 deletions Src/Runic/Runes/RuneMathFunc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,74 +64,75 @@ public bool Execute(Pointer pointer, IRunicContext context)
case '+':
char[] digits = x.ToString().ToCharArray();
int sum = 0;
foreach(char d in digits)
foreach (char d in digits)
{
sum += (d-48);
sum += (d - 48);
}
pointer.Push(sum);
break;
case '*':
digits = x.ToString().ToCharArray();
sum = 1;
foreach(char d in digits)
foreach (char d in digits)
{
sum *= (d - 48);
}
pointer.Push(sum);
break;
case '!':
int number = (int)x;
if(number == 0)
int number = (int) x;
if (number == 0)
{
pointer.Push(1);
break;
}
double fact = number;
for(int i = number - 1; i >= 1; i--)
for (int i = number - 1; i >= 1; i--)
{
fact *= i;
}
pointer.Push(fact);
break;
case '‼':
number = (int)x;
if(number == 0)
number = (int) x;
if (number == 0)
{
pointer.Push(1);
break;
}
fact = number;
for(int i = number - 2; i >= 1; i-=2)
for (int i = number - 2; i >= 1; i -= 2)
{
fact *= i;
}
pointer.Push(fact);
break;
case 'P':
pointer.Push(IsPrime((int)x) ? 1 : 0);
pointer.Push(IsPrime((int) x) ? 1 : 0);
break;
}
}
return true;
}

private bool IsPrime(int number) {
if(number < 2)
private bool IsPrime(int number)
{
if (number < 2)
return false;
if(number == 2)
if (number == 2)
return true;
if(number % 2 == 0)
if (number % 2 == 0)
return false;
if(number % 3 == 0)
if (number % 3 == 0)
return false;
double sq = System.Math.Sqrt(number);
for(int i = 5; i <= sq; i += 6)
for (int i = 5; i <= sq; i += 6)
{
if(number % i == 0)
if (number % i == 0)
return false;
if (number % (i + 2) == 0)
return false;
if(number % (i+2) == 0)
return false;
}
}
return true;
}
public IExecutableRune Register()
Expand Down

0 comments on commit 3e02c9b

Please sign in to comment.