cheap buy professional cialis online 20 mg. generic buy priligy no prescription. sildenafil no prescription 100 mg no rx.

on 20 juliol 2012 by joaquimperez in Ciència i tecnologia, Comments (0)

El llenguatge de programació Brainfuck

El llenguatges de programació més estrany de tots Brainfuck:

brainfuck command C equivalent
(Program Start) char array[30000];
char *ptr=array;
> ++ptr;
< --ptr;
+ ++*ptr;
- --*ptr;
. putchar(*ptr);
, *ptr=getchar();
[ while (*ptr) {
] }

En Brainfuck el programa típic Hello world que mostra per pantalla el text “Hello world” quedaria així:

 ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

 

Tot i així Brainfuck no és l’únic en la seva espècie, a Rosettacode.org, que vol ser la pedra Rosetta dels llenguatges de programació, descobreixo llenguatges tan curiosos com aquests:

el llenguatge J:

bubbleSort=:  (([ (<. , >.) {.@]) , }.@])/^:_

el llenguatge PicoLisp:

(de bubbleSort (Lst)
   (use Chg
      (loop
         (off Chg)
         (for (L Lst (cdr L) (cdr L))
            (when (> (car L) (cadr L))
               (xchg L (cdr L))
               (on Chg) ) )
         (NIL Chg Lst) ) ) )

el llenguatge Ursala:

#import nat
 
bubblesort "p" = @iNX ^=T ^llPrEZryPrzPlrPCXlQ/~& @l ~&aitB^?\~&a "p"?ahthPX/~&ahPfatPRC ~&ath2fahttPCPRC
 
#cast %nL
 
example = bubblesort(nleq) <362,212,449,270,677,247,567,532,140,315>

i el llenguatge Perl (molt famós però també força complicat de llegir si no es coneix):

sub bubble_sort (@a is rw) {
    for ^@a -> $i {
        for $i ^..^ @a -> $j {
            @a[$j] < @a[$i] and @a[$i, $j] = @a[$j, $i];
        }
    }
}

 

 

 

 

No hi ha comentaris

Deixa un comentari

XHTML: Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>