I think the quantity should be a grouping phrase equivalent to parentheses around the next sub-expression. define factorial of type int to int of n:
if n equals 0, then: return 1.
else: return n times factorial of the quantity n minus 1.
end.
define find of type pair of binary tree of pairs of keys and values, and key, to value or nil, of Tree and Key:
if Tree is nil, then return nil.
else if: Key is equal to Tree's key, then return Tree's value.
else if: Key is strictly less than Tree's key, then return find of Tree's left tree and Key.
else: return find of Tree's right tree and Key.
define factorial of type int to int of n:
if n equals 0, then:
return 1.
else:
let n accent be n minus 1 in:
return n times factorial of n accent.
end.
let n prime be seven times n,
n double prime be the square of n prime, and
n triple prime be the n primeth root of n double prime,
in the following:
return the subtraction of n triple prime and n double prime.
end.
Name:
sage2012-01-25 0:10
Why do I like this syntax? I hate myself.
Name:
Anonymous2012-01-25 0:19
>>17
I'm having trouble understanding the syntax. What would a function with two parameters look like? Say,
float foo(int a, float b)
{
return 2.0 * b + a;
}
Push the symbol, foo. Push the following subroutine: push 2.0, the multiple them, then add them. Define them.
Name:
Anonymous2012-01-25 0:57
>>23 define foo of type int and float to float of a and b:
return 2 times b plus a.
end
Maybe integer and binary could be integer types and real and computational could be floating-point types to make it more COBOL like. I think as 'type' would be a good syntax for casts, like b as integer.
foo is of type int and float to float.
define function foo of a and b:
return the addition of the multiplication of two point oh and b and a.
end.
?
foo is of type int and float to float.
define function foo of a and b:
let two b be the multiplication of two point oh and b, in the following:
return the addition of two b and a.
end.
?
foo is of type int and float to float.
define function foo of a and b:
return the multiplication of two point oh and b, followed by an addition by a.
end.
?
Name:
Anonymous2012-01-25 1:11
dot product is of type for all types satisfying multiplication and addition A, ordered collection of A and ordered collection of A to A:
define function dot product of X and Y:
reduce using addition of map using multiplication of X and Y.
end.
Name:
Anonymous2012-01-25 1:23
>>25-27 sum of ... reduce using addition of ... ... plus ... ... added to ... addition of ... by ... addition of ... to ... addition of ... and ... result of the addition of ... augend of ... add ... to ... add ... to ... giving ... add ... and ... giving ...
Name:
Anonymous2012-01-25 1:24
>>25
If it wasn't for the punctuation I think the syntax looks really nice, no symbols to be found. I know this is a joke in verbosity but looks really clean to me for some reason.
define foo of type int and float to float of a and b
return 2 times b plus a
end
[code]
But I guess when you compare it to something like
[code]
def foo(a int, b int) int
2*b+a
end
>>29
(In that the latter you don't have to really read from left-to-right, you can digest it just by looking at the shape of the code, and the former you actually have to read.)
yeah but reading is fun. I could see this being nice for functional stuff, but not so much for imperative. Or if it was imperative, it would be much more statementy, like:
Increment a.
Set b to b times b times a.
Set a to a plus b.
Goto Start.
Name:
Anonymous2012-01-25 2:51
>>31
This thread has made me smile. To be honest I find the syntax of languages like applescript somewhat appealing. Have any of you seen SK8? (The defunct project that steve jobs killed off). Scripts look like PLAIN ENGLISH as well.