08.02.2015 Views

Programação Funcional e Concorrente com Scheme

Programação Funcional e Concorrente com Scheme

Programação Funcional e Concorrente com Scheme

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

notas de aula - Jerônimo C. Pellegrini<br />

Queremos também um procedimento que mostra uma partícula em formato facilmente<br />

legível:<br />

( define particula- > string<br />

( lambda (p)<br />

( define position- > string<br />

( lambda (xy)<br />

( string-append "(x:" ( number- > string ( car xy ))<br />

" y:" ( number- > string ( cadr xy ))<br />

")" )))<br />

( string-append "p=" ( position- > string ( pos p))<br />

" m=" ( number- > string ( massa p))<br />

" v=" ( number- > string ( vel p))<br />

" a=" ( number- > string ( acel p )))))<br />

Agora podemos criar e manipular objetos do tipo particula:<br />

( faz-particula ’(2 3)<br />

3.0<br />

4.0<br />

1.5)<br />

(particula (2 3) 3.0 4.0 1.5)<br />

( let (( part ( faz-particula ’(2 3)<br />

3.0<br />

4.0<br />

1.5)))<br />

( display ( particula- > string part ))<br />

( newline )<br />

( set-pos ! part ’(4 5))<br />

( display ( particula- > string part ))<br />

( newline ))<br />

p=(x:2 y:3) m=3.0 v=4.0 a=1.5<br />

Versão Preliminar<br />

p=(x:4 y:5) m=3.0 v=4.0 a=1.5<br />

O esquema de representação que desenvolvemos é insatisfatório:<br />

186<br />

[ 27 de outubro de 2010 at 15:47 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!