And this is my second site created with appengine: http://javarubyscala.appspot.com/view/StartPage
lunedì 3 novembre 2008
mercoledì 22 ottobre 2008
My first Google App Engine test !!!
Pubblicato da koteth 0 commenti
martedì 14 ottobre 2008
Mandelbrot in Scala
I'm also working on a more complex mandelbrot set program in Scala.
Soon i'll post the source code.
This is the output:
Pubblicato da koteth 0 commenti
Esoteric ruby Mandelbrot
Inspired from this article i've decided to
play with code in order to create my version of Madelbrot set program in ruby.
This is the code:
( not true, the code is here because the blogger editor didn't work fine when a code contain <
or > )
The code is intentionally obscure.
Is possible to decide: position, zoom factor, number of iterations, and number of lines.
The output should be like this:
Pubblicato da koteth 0 commenti
domenica 5 ottobre 2008
Vedic Math first lesson
the Sutra says: "By one more than the previous one".
With this sutra you can calculate mentally this fraction:
easy, isn't it?
In the next few days i'll give the explanation of this method.
Pubblicato da koteth 0 commenti
Etichette: math, vedic math
sabato 4 ottobre 2008
Code reduction ( obfuscation in ruby code )
This ruby code is equivalent to the code in previous post
N = 13; k = N-1; r = (1..k).to_a ; e = [r.first, r.last];
r.each{a print(r.map{b e.include?(b*a%N)?"1 ":" "},"\n")}
Pubblicato da koteth 0 commenti
Etichette: ruby
venerdì 3 ottobre 2008
My first Ruby program!
This is my first Ruby program!
N = 13
def un( el, en )
[1, en-1].include?(el%en)?re=1:re=" "; return re
end
(N-1).times do a
(1...N-1).to_a.each{b print un((b+1)*(a+1),N), " "}
print "\n"
end
A little obscure, isn't it?The output is ( as desired ):
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
The same program in Scala can be written in this way:
object something {
val un = ( el:Double, en:Double ) =>
if( Array(1,en-1).contains( el%en) ) "1 " else " "
def main(args : Array[String]) : Unit = {
val N = 23
for(i <- 1 to N-1){ new Array(N-1)
.indices.foreach(el => print( un((el+1)*(i),N) ))
println()
}
}
}
and the output with N=23 is:
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
Pubblicato da koteth 0 commenti
giovedì 2 ottobre 2008
"Eyes follow mouse" in js
here is my interpretation of "eyes follow mouse" in javascript.
Nothing special but works fine.
an important function in this js is this one:
function objMove( obj, xPos, yPos ){
obj.style.left = xPos + "px";
obj.style.top = yPos + "px";
}
is a function that move an object of the page.
the important thing is that works with ie, opera and firefox
an example of this eyes follow mouse at work.
Pubblicato da koteth 0 commenti
lunedì 29 settembre 2008
xml viewer in Scala
graphically
The idea is to create a graphical editor for xml and processDefiniton
of Jbpm.
Pubblicato da koteth 0 commenti
venerdì 26 settembre 2008
Haar wavelet transform in Scala
This is my first try to write a wavelet(ondine in Italian) transform in Scala.
Naturally i've choose Haar wavelet transform, the simplest!
This is the core of the transformation:
def waveletCalc( values: List[Double] ):List[List[Double]]=
haarCalc( values , List( ) ).reverse
def haarCalc( vals: List[Double], cc: List[List[Double]] )
:List[List[Double]] =
vals.length / 2 match {
case 1 => cc ::: List( List((vals(0) - vals(1) ) / 2 ) ,
List(( vals(0) + vals(1) ) / 2 ))
case _ => haarCalc( vals.indices.dropRight(vals.length/2)
.map(_*2).map(el=>(vals(el) + vals(el+1))/2),
cc ::: List( vals.indices.dropRight(
vals.length/2).map(2*_).map(el=>
(vals (el) - vals(el + 1))/2)))
}
The algorithm is recursive and returns as a result a list of lists.
This arrangement is the most convenient since a base of wavelets has two indexes.
Soon i'll try to post the complete class with the inverse transform and a brief
description on this particular wavelets transform.
I strongly recommend to copy and paste the code in an editor to read it better...
you can find a more complete code here
Pubblicato da koteth 0 commenti
mercoledì 24 settembre 2008
Algebraic group
Today I started to write a class in Scala to represent a group (in the mathematical sense).
To test closure, i.e.:
the code I wrote is:
def closure( ): Boolean =
elements.forall(
el => elements.forall(
el2 => elements.exists(
el2.*(el, this).name == _.name ) ) )
'elements' is the list of all group elements and and each element has a different 'name'.
The following piece of code is the product of two elements.
el2.*(el, this)
the * operator is defined as follows:
def *( b : groupElement ,group: genericGroup ) : groupElement
we can write a test like this in a way so simple!
Pubblicato da koteth 1 commenti
a Snapshot of my new Jung-Scala project
Pubblicato da koteth 1 commenti
lunedì 22 settembre 2008
Fast Fourier transform
Fast Fourier transform in Scala
http://sites.google.com/site/snakelemma/snippets/fftShort.scala?attredirects=0
Pubblicato da koteth 0 commenti
sabato 13 settembre 2008
Complx.scala
simple Complex number class in Scala programming language
http://sites.google.com/site/snakelemma/snippets/complx.scala?attredirects=0
Pubblicato da koteth 0 commenti
domenica 7 settembre 2008
little scala snippet
def showRow(arra: Array[int], molt: int, mod: int ,unitari : boolean ):Array[int] = {
val a2 = arra.map( s => ( s * molt ) % mod )
if ( unitari )
println ( a2.map( s => if ( s == 1 s == ( mod -1 ) ) 1 else 0 ).toString )
else
println( a2.toString )
a2
}
def shoMatr( mod: int , unitari : boolean ) {
println( if ( unitari ) "elementi unitari" else "tabella moltiplicativa" )
val array = new Array[int]( mod - 1 ).indices.map( s => s + 1 )
array.foreach( p => showRow( array , ( array indexOf p ) + 1 , mod , unitari ) )
}
Pubblicato da koteth 0 commenti