Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Ugliness test

Name: Anonymous 2012-11-30 12:31

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: Anonymous 2012-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);
    }
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List