Skip to content

Primitivas

El lenguaje incluye diversas funciones pre-definidas (primitivas). Algunas de estas se muestran a continuación.

Operadores unarios y binarios

Operador Código de ejemplo Resultado
not (not #t) #f
+ (+ 4 5) 9
- (- 6 3) 3
* (* 2 3) 6
/ (/ 6 2) 3
> (> 4 3) #t
< (< 4 3) #f
>= (>= 5 6) #f
<= (<= 5 6) #t
equal? (equal? 3 (+ 1 2)) #t
mod (mod 2 6) 2

Predicados

Operador Código de ejemplo Resultado
member? (member? (list 1 2 3) 3) True
starts-with? (starts-with? 'potato' 'pot') True
ends-with? (ends-with? 'potato' 'to') True
contains? (contanis 'potato' 'do') False
any-satisfy? (any-satisfy? (fun (x) (equal? x 3)) (list 1 2 3 4)) True

Tipos

Operador Código de ejemplo Resultado
CONVERSIÓN DE TIPOS
str (str 666) '666'
num (num "666") 666
int (int "666") 666
CHEQUEO DE TIPOS
nil? (nil? nil) True
bool? (bool? #t) True
str? (str? 2) False
num? (num? 6.1212121) True
int? (int? -667) True
list? (list? (list 1 2 3)) True
ALEATORIOS
uuid () ''
random (random 0 5) número entre 0 y 5

String

Operador Código de ejemplo Resultado
split (split "perro,gato,zapallo" ",") ['perro', 'gato', 'zapallo']
join (join ", " (list "pollos" "pavos" "iguana")) 'pollos, pavos, iguana'
plain (plain "ÉnTérO BellákO") 'entero bellako'
uppercase (uppercase "AbCdEfgH") 'ABCDEFGH'
lowercase (lowercase "AbCdEfgH") 'abcdefgh'
capitalize (capitalize "aleluya hmno") 'Aleluya hmno'
replace (replace "muajaja" "j" "h") 'muahaha'
reverse (reverse "sergio") 'oigres'
trim (trim " hola, soy julito ") 'hola, soy julito'
append (append "holi" "hola") 'holihola'
match? (match? ".pedro." "hola pedro, como estas?") TRUE

Fechas y tiempos

Primitiva Código de ejemplo
timestamp (timestamp)
time-now (time-now)
time-delta-seconds (time-delta-seconds init_time 30)
time-delta-minutes (time-delta-minutes init_time 30)
time-delta-hours (time-delta-hours init_time 30)
time-delta-days (time-delta-days init_time 30)
time-from-string (time-from-string "30 Nov 00" "%d %b %y")
time-to-string ()

HTTP

Primitiva Código de ejemplo
http-get (http-get "http://example.com")
http-post (http-post "http://some.url" payload headers)
http-pos-form (http-post-form "http://some.url" payload headers)
uri-escape (uri-escape "Pascual Baburizza 595")

Otros operadores

Operador Código de ejemplo Resultado
COMPRESSION
bz2-compress (bz2-compress "{0}")
bz2-decompress (bz2-decompress "{0}")
BASE-64
b64-encode (b64-encode "hólá") 'aMOzbMOh'
b64-decode (b64-decode "aMOzbMOh") 'hólá'