Created
August 23, 2011 15:48
-
-
Save vietnt/1165535 to your computer and use it in GitHub Desktop.
new language
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int Sum(int[] list) | |
<- 0 += x in list | |
int Max(int[] list) | |
<- max = x | |
if x > max | |
x in list | |
max = int.MinValue | |
QSort(int[] list, int lo, int hi) | |
QSort (list, lo, l) | |
QSort (list, h, hi) | |
x = list[(lo + hi)/2] | |
l = lo | |
h = hi | |
while (l <= h) | |
l++ while (list[l] < x) | |
h-- while (list[h] > x) | |
l <= h ? | |
list[h,l] = list[l,h] | |
l++ | |
h++ | |
#Add all the natural numbers below one thousand that are multiples of 3 or 5. | |
ProjectEulerProblemOne() | |
Console.WriteLine (sum) | |
sum <- 0 += x | |
if x%3==0 || x%5 ==0 | |
x in [1,1000) | |
#sum <- += [1,1000) % (3||5) == 0 | |
# By considering the terms in the Fibonacci sequence whose values | |
# do not exceed four million, find the sum of the even-valued terms. | |
ProjectEulerProblemTwo() | |
Console.WriteLine (sum) | |
sum <- 0 += x | |
for x, y | |
1, 1 | |
y, x + y, | |
x <= 4e6 | |
if x % 2 == 0 | |
# Find the largest prime factor of a composite number. | |
ProjectEulerProblemThree() | |
Console.WriteLine (r) | |
r = x | |
if n%x == 0 && x% [2,sqrt(x)] != 0 | |
x in [2, sqrt(n)] | |
n = 600851475143 | |
ProjectEulerProblemFour() | |
Console.WriteLine(r) | |
r = (x*y).ToString() | |
if r == r.ToCharArray().Reverse().ToString() | |
x in (1000,100] | |
y in [x-1,100] | |
New(Type impl, Stack<Type> traces) | |
<- constructor.Invoke (args) | |
constructor = impl.GetConstructors()[0] | |
args = new object[parameters.Length] | |
[i] = New(type, traces) | |
type = (p in parameters).ParameterType | |
throw new CicurlarDependencyException (traces.ToArray()) | |
if type in traces | |
parameters = constructor.GetParameters() | |
try | |
traces.Push(impl) | |
finally | |
traces.Pop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment