Lisp
From Wikipedia, the free encyclopedia
From Wikipedia, the free encyclopedia
Lisp ye un luengache de programación funcional. Creyato en 1958, ye o segundo luengache de programación mas antigo dimpués de Fortran. Os principals dialectos de Lisp son Common Lisp y Scheme.
Iste articlo ye en proceso de cambio enta la ortografía oficial de Biquipedia (la Ortografía de l'aragonés de l'Academia Aragonesa d'a Luenga). Puez aduyar a completar este proceso revisando l'articlo, fendo-ie los cambios ortograficos necesarios y sacando dimpués ista plantilla. |
La base d'a programación en Lisp ye a lista. En Lisp bi ha dos menas d'elementos:
Lisp emplega a notación prefixa u polaca inversa.
Astí bi ha bellos eixemplos de codigo en Lisp.
La sintaxi de Lisp ye mui apropiata ta la programación recursiva, por eixemplo lo factorial d'un numero se calcula:
(defun factorial (n)
(if (<= n 1)
1
(* n (factorial (- n 1) ) )
)
)
Atra versión alternativa mas rapeda que l'anterior ye:
(defun factorial (n &optional (acc 1))
(if (<= n 1)
acc
(factorial (- n 1) (* acc n) )
)
)
Os bucles no existiban en o Lisp puro, pero si se pueden fer programas iterativos en Common Lisp con a instrucción loop
:
(defun factorial (n)
(loop for i from 1 to n
for fac = 1 then (* fac i)
finally (return fac)
)
)
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.