I'm making a new language. I think I have already fixed most of design flaws, but I need to check it first before writing a real interpreter.
Post your code snippets, I will translate them to my lang and we will decide whether they are beautiful enough.
Name:
Anonymous2012-11-30 13:44
obligatory fibs, factorial, higher-order functions, extensible numeric tower including rationals, complex, gaussian integers, etc.
Name:
Anonymous2012-11-30 13:59
Translate this!
gui D = M:[0 0] = C:\point = Exit:ø = FI:<E=ø> = FP:[0 0] = LI:<E=ø> = LCT:0
= Pop:ø = G:gfx 1 1 = R:o
render:<= R:D'render = {F:R.proxy = {G'w≤≥R'w |v G'h≤≥R'h = !G: gfx R'w R'h}
= F 0 0 G = !R:G
;√ = !R:R'copy}
= C,cursor,<C:y = P:M-C'hs = R.blit @P C
= {FG:Pop |a Pop'render = R.blit @(P-[0 FG'h]) FG}
>
= {Exit=ø;R}>
itemAt:<M P W = {F:W.items = F,c | fnd:[R I] inRect R M
| <[[X Y @_] I] = itemAt M-[X Y] P+[X Y] I; _=[P W]>
;√ = [P W]}>
exit:<R=!Exit:[R]>
input:<Es = SGUI:GUI = !GUI:Me = T:time,c,flt = Ts:Timers = !Timers:ø
= !Ts | filter:[I N F] {T≤N=[I N F]; F,c=[I time,c,flt+I F]} = [@Ts @!Timers]
= [NP NW]: itemAt M [0 0] D = NI:{NW.input;<E=ø>} = !Pop:{F:NW.popup=F,c}
= !C: {F:NW.cursor=F,c} |v \point
= Es | e <[N S]
= {N,<\mice_move = !M:S = NI [N S S-NP] = √> |a n (ptrEq LI NI)
//= pp [NW {F:NW.items=F,c}]
= LI [\mice_over ø M] = !LI:NI = LI [\mice_over √ M]
;N,<\mice_left;\mice_right> |a S
= {ptrEq FI NI =
;√ = FI [\focus ø M-FP] = !FI:NI = !FP:NP
= FI [\focus √ M-FP]}
= {T-LCT≤1/4 = FI [“double_$(d 5 N)” √ M-FP]} = !LCT:T}
= FI [N S M-FP]>
= !GUI:SGUI = Me>
= sdl (R.input ? |h render) = Exit,0
Name:
Anonymous2012-11-30 14:11
import scala.math
class Complex (real: Double, imaginary: Double) {
def x = real
def y = imaginary
def conj = new Complex(real, 0 - imaginary)
def mod = math.sqrt(this.x * this.x + this.y * this.y)
def arg = math.atan2(this.x, this.y)
override def toString() = "" + x + (if (y < 0) "" else "+") + y + "i"
}
object Main {
def main(args: Array[String])
{
val z = new Complex(1.2, 3.4)
printf("z = %s, z* = %s, |z| = %f, arg z = %f", z.toString(),
z.conj.toString(), z.mod, z.arg);
}
}
Name:
Anonymous2012-11-30 14:25
echo "content" > file
Name:
Anonymous2012-11-30 14:37
>>4
Symta:
complex Real Imaginary = X:Real = Y:Imaginary = o conj:<= complex Real 0 - Imaginary>
mod:<= sqrt X^2 + Y^2> arg:<= atan2 X Y> _prn:<=“$X${Y≤0;“+”}$(Y)i”>
= Z: complex 1.2 3.4 = p “Z = $Z, Z* = $(Z'conj), |Z| = $(Z'mod), arg Z = $(Z'arg)”
Scala:
import scala.math
class Complex (real: Double, imaginary: Double) {
def x = real
def y = imaginary
def conj = new Complex(real, 0 - imaginary)
def mod = math.sqrt(this.x * this.x + this.y * this.y)
def arg = math.atan2(this.x, this.y)
override def toString() = "" + x + (if (y < 0) "" else "+") + y + "i"
}
object Main {
def main(args: Array[String])
{
val z = new Complex(1.2, 3.4)
printf("z = %s, z* = %s, |z| = %f, arg z = %f", z.toString(),
z.conj.toString(), z.mod, z.arg);
}
}
>>2
## tail-recursive fibs and fact with default/optional args
fib[n, {a, 0}, {b, 1}] :- {
n => {
0 : a,
n, {#when : n > 0} : fib[n - 1, #a : b, #b : b + a]
}
},
factorial[n, {acc, 1}] :- {
n => {
0 : acc,
n, {#when : n > 0} : factorial[n - 1, #acc : n * acc]
}
},
## postfix factorial operator
(!) :: {
{{n} {} factorial[n]}
},
10 ! ## will be transformed into "factorial[10]" >>4
Complex numbers are part of the language:
z :- 1.2i3.4,
display[#format : "z = ~s, z* = ~s, |z| = ~f, arg z = ~f",
z, conjugate[z], abs[z], argument[z]]
Name:
Anonymous2012-12-01 2:54
>>3
Translate line-noise with no proper documentation? No, thanks.
Name:
Anonymous2012-12-01 2:59
>>5
It would possibly look like `system["echo 'content' > file"]`. I didn't think about file operations yet. >>10
If ANUS is a class then anus :- ANUS[] >>12 CALL/CC CONSIDERED HARMFUL
>>28
1,2:
If you see unknown operator, you call it ugly? Great!
"=>" is a `match` operator.
"::" is a `define-operator` operator.
3:
In case you see "(lambda () ...)" do you complain about empty parens?
4:
You can use display without formatting string. What's the problem?
>LE LELLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
>LE MEME FACE WHEN
>LE MEME FACE WHEN
>LEEEEEEEEEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
>EGIN!
>EGINGIN!!!!
>EGINGINGWIM!!!!!!!!!!!!!!!!!!!!!!!!
>MY LEL FACE WHEN LE /G/RO IS FUQIN EGIN
Name:
Anonymous2012-12-01 20:05
>>24
static typing is great if your goal is carpal tunnel