yorick: a scientific language

[top]

  1. C like syntax, but many at a time like APL.
  2. Very powerful array indexing.
  3. Example: Prime number generation by two distinct algorithm(see APL, A+, J, K, Q'Nial version).

    func primes(n)
    /* DOCUMENT primes(n)
       Prime number generation by outer product.
     */
    {
        return where(2 == (0 == (v = indgen(n))(-,)%v)(sum,));
    }
    
    func sieve(n)
    /* DOCUMENT sieve(n)
       Prime number generation by sieve of Eratosthenes.
     */
    {
        tbl = array(1, n);
        tbl(1) = 0;
        for (i = 2; i + i <= n; ++i) {
    	if (tbl(i))
    	    tbl(indgen(i + i : n : i)) = 0;
        }
        return where(tbl > 0);
    }
    

[top]