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 />

My text!<br />

<br />

2.3 gráficos vetoriais<br />

(esta seção está in<strong>com</strong>pleta)<br />

O formato SVG para gráficos vetoriais é XML. Construiremos uma biblioteca para<br />

construção de gráficos vetoriais, e os gravaremos usando nosso gerador de XML.<br />

Primeiro faremos um procedimento que aceita <strong>com</strong>o argumentos atributos e valores,<br />

e os devolva em uma lista, <strong>com</strong> os valores transformados em string (porque é desta forma<br />

que atributos XML são escritos).<br />

O procedimento auxiliar number->string/maybe transforma números em strings, mas<br />

mantém os outros valores intactos.<br />

( define number- > string / maybe<br />

( lambda (x)<br />

(if ( number x)<br />

( number- > string x)<br />

x )))<br />

(number->string/maybe 10)<br />

”10”<br />

(number->string/maybe ’x)<br />

x<br />

( define make-attr-list<br />

( lambda args<br />

( map number- > string / maybe args )))<br />

(make-attr-list ’x 1 ’y 2 ’z 3)<br />

Versão Preliminar<br />

(x "1"y "2"z "3")<br />

72<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!