Solution of Erek Gokturk


; Extracts the nth digit of the number
( define ( basamak n sayi )
   ( floor ( / ( remainder sayi ( expt 10 n ) ) ( expt 10 ( - n 1 ) ) ) ) )

; Writes a single digit
( define ( rakam-yaz rakam )
   ( item rakam '( bir iki uc dort bes alti yedi sekiz dokuz ) ) )

; Writes the tenths digit according to the number 'onluk'
( define ( onluk-yaz onluk )
   ( item onluk '( on yirmi otuz kirk elli altmis yetmis seksen doksan ) ) )

; Reads the number digit by digit
( define ( ic-oku sayi )
   ( sentence
        ( and ( not ( = ( basamak 4 sayi ) 0 ) )
	      ( if ( = ( basamak 4 sayi ) 1 )
		 'bin ( sentence ( rakam-yaz ( basamak 4 sayi ) ) 'bin )))
        ( and ( not ( = ( basamak 3 sayi ) 0 ) )
	      ( if ( = ( basamak 3 sayi ) 1 )
		 'yuz ( sentence ( rakam-yaz ( basamak 3 sayi ) ) 'yuz )))
	( and ( not ( = ( basamak 2 sayi ) 0 ) )
	      ( onluk-yaz ( basamak 2 sayi ) ))
	( and ( not ( = ( basamak 1 sayi ) 0 ) )
	      ( rakam-yaz ( basamak 1 sayi ) ) ) ) ) 

; Checks the bounds of the number ( and whether it is a number or not )
; If it can be read, reads it by calling ic-oku
( define ( convert sayi )
    ( if ( number? sayi )
       ( if ( > sayi 9999 )
          ( word '"In school we have not seen yet how to express this!" )
          ( if ( < sayi 0 )
             ( sentence 'eksi ( ic-oku ( - sayi ) ) )
             ( if ( = sayi 0 ) 'sifir ( ic-oku sayi ) ) ) )
       ( word '"The argument is not an integer" ) ) )