Está en la página 1de 1

Erlang Haskell Scheme

Extensin .erl .hs


Definir variables
Guardar archivo con la
variable

Ejemplo: var.hs

a !
:load var.hs permite utili"ar
las variables almacenadas en
el archivo.

#et a !

a a $ ! %
! !$!

&omentarios
' (( &omenta
{- Comenta -}

)peradores matem*ticos
$(+
div% rem
,ase-.alue
$ ( + ^
/uot% rem

0unciones
function123 (4
Expression5
0uncion x
Ejemplo:
6rea x x78
6rea 9
6rearect l a

&uadruple x Doble1Doble x3

)peradores booleanos
6nd

)r

:ot
!4 true and false.
false
84 false or true.
;rue
and <<
1= > ?3 << 10alse 0alse3
or ||
1@@3 1!? !A3 1B 4 !!3

:ot not
x C D not 1x D3

;ipo de datos
isEatomC! isEbinarDC!
isEbitstringC! isEbooleanC!
isEfloatC! isEfunctionC!
isEintegerC! isElistC!
isEnumberC!

:tDpe ;rue
;rue :: ,ool

&har
String F
:um Gnt% Gnteger%0loat%
Double

GnputC)utput
receive Hsg(4


io:format1IJpJnI%
KHsgL3


fMrite
get#ine

putStr#n

do
putStr#n IEscriba su
nombre: I
name >( get#ine
putStr#n 1IHola% I $$ name
$$ I% N&omo estasOI3

6rreglosC#istas
!4 2 !P% Q R.
R
84 Soint T2%QU.

!4 K!% 8% =% Tnumbers%KR%9%VLU% 9.=R%
atomL.
K!%8%=%Tnumbers%KR%9%VLU%9.=R%atomL

94 K!%8%=L $$ KR%9L.
K!%8%=%R%9L
V4 K!%8%=%R%9L (( K!%8%=L.
KR%9L
let numbers
let truths K;rue% 0alse%
0alseL
let strings

Srelude4 numbers
K!%8%=%RL
Srelude4 P:numbers
KP%!%8%=%RL

Wecursin
fac1P3 (4 !5
fac1:3 Mhen : 4 P (4 :+fac1:(!3.
let T factorial P !5 factorial n
n + factorial 1n ( !3 U

Estructuras de control
if 2 4 Q (4 a13
5 2 > Q (4 b13
5 2 Q (4 c13
end

insert12%Set3 (4
case lists:member12%Set3 of
true (4 Set5
false (4 K2@SetL
end.
if >condition4 then >true(
value4 else >false(value4

f x
case x of
P (4 !?
! (4 !9
8 (4 !8
E (4 !8 ( x

También podría gustarte