PDA

View Full Version : [Lisp] Urgente! Funzioni che ritornano 2 valori


Mezzelfo
10-11-2007, 22:21
Ciao a tutti!
C'č qualcuno che conosce Lisp?

Ho installato cl-ppcre (http://www.weitz.de/cl-ppcre/)

Mi serve la funzione scan-to-strings

scan-to-strings regex target-string &key start end sharedp => match, regs

Like SCAN but returns substrings of target-string instead of positions, i.e. this function returns two values on success: the whole match as a string plus an array of substrings (or NILs) corresponding to the matched registers. If sharedp is true, the substrings may share structure with target-string.

Perņ quello che mi serve č il secondo valore che ritorna, l'array con le sottostringhe. Come faccio ad utilizzarlo?
Se faccio ad esempio
(list (cl-ppcre:scan-to-strings "REGEX" "STRINGA"))
Ottengo
("STRINGA")
Senza nessuna traccia dell'array, che viene tranquillamente stampato a video dall'interprete se lancio
(cl-ppcre:scan-to-strings "REGEX" "STRINGA")
"STRINGA" ;
#("SOTTOSTRINGA1" "SOTTOSTRINGA2" "ECC")

Grazie

Mezzelfo
10-11-2007, 23:00
Trovato:
multiple-value-bind
Ora vediamo cerchiamo come si usano i vector. :D

marco.r
11-11-2007, 01:26
Cerca nella rete "Pratical Common Lisp", e' gratuito, fatto molto bene (perlomeno secondo il mio profano parere) e copre un po' di tutto. Oltre a questo dedica interi capitoli ad esempi pratici affatto banali: tra gli altri spiega come costruire passo-passo un framework per gli unit test, un server shoutcast e un filtro spam.
Che interprete/compilatore stai usando ?

Mezzelfo
11-11-2007, 02:12
Grazie dell'info.
Sto usando clisp.