Brainfuck Eduki-taula Lengoaiaren diseinua | Adibideak | Nabigazio menua
Programazio lengoaia esoterikoak
programazio lengoaia esoterikoa1993Turing osoakonpiladoreTuringen makinanFALSE
(function()var node=document.getElementById("mw-dismissablenotice-anonplace");if(node)node.outerHTML="u003Cdiv class="mw-dismissable-notice"u003Eu003Cdiv class="mw-dismissable-notice-close"u003Eu003Ca tabindex="0" role="button"u003Eⓧu003C/au003Eu003C/divu003Eu003Cdiv class="mw-dismissable-notice-body"u003Eu003Cdiv id="localNotice" lang="eu" dir="ltr"u003Eu003Ctable style="width: 100%;"u003Enu003Ctbodyu003Eu003Ctru003Enu003Ctdu003Enu003Cul class="gallery mw-gallery-packed"u003Enttu003Cli class="gallerybox" style="width: 452px"u003Eu003Cdiv style="width: 452px"u003Entttu003Cdiv class="thumb" style="width: 450px;"u003Eu003Cdiv style="margin:0px auto;"u003Eu003Ca href="https://eu.wikipedia.org/wiki/Atari:Ondarea/WikiLovesMonuments_2019"u003Eu003Cimg alt="Wlm-2019-argazki-lehiaketa.jpg" src="//upload.wikimedia.org/wikipedia/commons/7/7e/Wlm-2019-argazki-lehiaketa.jpg" decoding="async" width="450" height="90" data-file-width="500" data-file-height="100" /u003Eu003C/au003Eu003C/divu003Eu003C/divu003Entttu003Cdiv class="gallerytext"u003Entttu003C/divu003Enttu003C/divu003Eu003C/liu003Enu003C/ulu003Enu003C/tdu003Enu003Ctdu003Enu003Cul class="gallery mw-gallery-packed"u003Enttu003Cli class="gallerybox" style="width: 452px"u003Eu003Cdiv style="width: 452px"u003Entttu003Cdiv class="thumb" style="width: 450px;"u003Eu003Cdiv style="margin:0px auto;"u003Eu003Ca href="https://eu.wikipedia.org/wiki/Atari:Hezkuntza/Lehiaketak/2019/WLM"u003Eu003Cimg alt="Wlm-2019-edizio-lehiaketa.jpg" src="//upload.wikimedia.org/wikipedia/commons/b/bd/Wlm-2019-edizio-lehiaketa.jpg" decoding="async" width="450" height="90" data-file-width="500" data-file-height="100" /u003Eu003C/au003Eu003C/divu003Eu003C/divu003Entttu003Cdiv class="gallerytext"u003Entttu003C/divu003Enttu003C/divu003Eu003C/liu003Enu003C/ulu003Enu003C/tdu003Enu003Ctdu003Enu003Cul class="gallery mw-gallery-packed"u003Enttu003Cli class="gallerybox" style="width: 452px"u003Eu003Cdiv style="width: 452px"u003Entttu003Cdiv class="thumb" style="width: 450px;"u003Eu003Cdiv style="margin:0px auto;"u003Eu003Ca href="https://eu.wikipedia.org/wiki/Atari:Hezkuntza/Lehiaketak/2019/09"u003Eu003Cimg alt="2019-09-lehiaketa.jpg" src="//upload.wikimedia.org/wikipedia/commons/5/56/2019-09-lehiaketa.jpg" decoding="async" width="450" height="90" data-file-width="500" data-file-height="100" /u003Eu003C/au003Eu003C/divu003Eu003C/divu003Entttu003Cdiv class="gallerytext"u003Entttu003C/divu003Enttu003C/divu003Eu003C/liu003Enu003C/ulu003Enu003C/tdu003Eu003C/tru003Eu003C/tbodyu003Eu003C/tableu003Eu003C/divu003Eu003C/divu003Eu003C/divu003E";());
Brainfuck
Jump to navigation
Jump to search
Brainfuck, programazio lengoaia esoterikoa da, Urban Müller-ek diseinatuta 1993. urtean. Helburutzat lengoaia sinplea eraikitzea zen, Turing osoa eta konpiladore txiki behar zuena. Brainfuck Turingen makinan oinarritu zen, eta 1024 byteko konpiladoreari inspirazio gisa erabili zen, FALSE lengoaian erabiliko zena.
Eduki-taula
1 Lengoaiaren diseinua
1.1 Aginduak
1.2 Beste lengoaietara itzuli
2 Adibideak
2.1 Kaixo mundua!
2.2 Bizitzaren jokoa.
2.3 Sierpinskiren triangelua
Lengoaiaren diseinua |
Lengoaia exekuzio modelo sinple batean oinarritzen da, programaz aparte, bektore bat 30000 bytekoa (0ra hasieratutakoak), erakusle bat bektore horretara erakusten duena (hasieran bektorearen lehengo elementura erakusten du) eta bi byte “korronte” sarrera eta irteera burutzeko.
Aginduak |
8 agindu ditu soilik, guztiak karaktere bakarrekoak.
Karakterea | Esanahia |
---|---|
> | Erakuslea gehitzen du. |
< | Erakuslea kentzen du. |
+ | Erakutsitako bytea gehitzen du. |
- | Erakutsitako bytea kentzen du. |
. | Erakutsitako bytearen irteeran idatzi. |
, | Byte bat irakurri sarreratik eta erakutsitako bytean gorde. |
[ | Aurreratu ] ren ondorengo agindura baldin eta erakutsitutako bytea nulua bada (0 bada). |
] | Itzuli [ ren ondorengo agindura baldin eta erakutsitutako bytea nulua ez bada (0 ez bada). |
Beste lengoaietara itzuli |
Brainfuck programak C eta Perl lengoaietara itzuli daitezke honako aldaketag eginez. Suposatuz ptr
aldagaia unsigned char*
motakoa dela.
brainfuck | C | Perl |
---|---|---|
> | ++ptr; | $pointer++; |
< | --ptr; | $pointer--; |
+ | ++*ptr; | $tape[$pointer]++; |
- | --*ptr; | $tape[$pointer]--; |
. | putchar(*ptr); | print chr$tape[$pointer]; |
, | *ptr=getchar(); | $tape[$pointer]=ord(<>); |
[ | while (*ptr) | while($tape[$pointer]) |
] |
|
|
Adibideak |
Kaixo mundua! |
++++++++++
[ Memoriak hasieratzeko begizta (10 aldiz errepikatuko da)
>+++++++>++++++++++>+++++++++++>+++>+<<<<<-
70 100 110 30 10
]
>++. inprimatu 'H' (72) 1
>>+. inprimatu 'o' (111) 3
---. 'l' (108) 3
<---. 'a' (97) 2
>>++. hutsunea (32) 4
<+. 'm' (109) 3
++++++++. 'u' (117) 3
-------. 'n' (110) 3
<+++. 'd' (100) 2
>+. 'o' (111) 3
>+. '!' (33) 4
>. 'n' (10) 5
Honako kode honek "Hello World!" idatziko luke, lerro bakarrean:
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
Hutsuneak, tabulazioak eta lerro jauziek ez dute kodean inolako eraginik.
Bizitzaren jokoa. |
Linus Akesson presents:
The Game Of Life implemented in Brainfuck
+>>++++[<++++>-]<[<++++++>-]+[<[>>>>+<<<<-]>>>>[<<<<+>>>>>>+<<-]<+
+++[>++++++++<-]>.[-]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[-]]<<<<<<<[>>>>>>>>>>>>+>+<<<<<<<<<<<<<-][ lft@df.lth.se ]>>>>>
>>>>>>>[-[>>>>+<<<<-]>[>>>>+<<<<-]>[>>>>+<<<<-]>>]>>>[-]<[>+<-]<[-[<<<<+>>
>>-]<<<<]<<<<<<[-]]<<<<<<<[-]<<<<-]<-]>>>>>>>>>>>[-]<<]<<<<<<<<<<]
Type for instance "fg" to toggle the cell at row f and column g
Hit enter to calculate the next generation
Type q to quit
Sierpinskiren triangelua |
[ This program prints Sierpinski triangle on 80-column display.]
>
++
++
[<++
++
++++
>-]>
++++++++
[>
++++
<-]>
>++>>>+>
>>+<
<<<<<<<<
<[-[->+<
]>[-<+>>>.<<]>>>
[[
->++
++++
++[>++++
<-]>
.<<[->+<
]+>[->++
++++++++<<+>]>.[
-]>]
]+<<<[-[
->+<]+>[
-<+>>>-[->+<]++>
[-<->]<<
<]<<<<]+++++++++
+.+++.[-]<]+++++
* * * * * M a d e * B y : * N Y Y R I K K I * 2 0 0 2 * * * * *
(RLQ=window.RLQ||[]).push(function()mw.log.warn("Gadget "ErrefAurrebista" was not loaded. Please migrate it to use ResourceLoader. See u003Chttps://eu.wikipedia.org/wiki/Berezi:Gadgetaku003E."););
Kategoria:
- Programazio lengoaia esoterikoak
(RLQ=window.RLQ||[]).push(function()mw.config.set("wgPageParseReport":"limitreport":"cputime":"0.112","walltime":"0.662","ppvisitednodes":"value":47,"limit":1000000,"ppgeneratednodes":"value":0,"limit":1500000,"postexpandincludesize":"value":0,"limit":2097152,"templateargumentsize":"value":0,"limit":2097152,"expansiondepth":"value":2,"limit":40,"expensivefunctioncount":"value":0,"limit":500,"unstrip-depth":"value":0,"limit":20,"unstrip-size":"value":59014,"limit":5000000,"entityaccesscount":"value":0,"limit":400,"timingprofile":["100.00% 0.000 1 -total"],"cachereport":"origin":"mw1272","timestamp":"20190828205019","ttl":2592000,"transientcontent":false););"@context":"https://schema.org","@type":"Article","name":"Brainfuck","url":"https://eu.wikipedia.org/wiki/Brainfuck","sameAs":"http://www.wikidata.org/entity/Q244627","mainEntity":"http://www.wikidata.org/entity/Q244627","author":"@type":"Organization","name":"Contributors to Wikimedia projects","publisher":"@type":"Organization","name":"Wikimedia Foundation, Inc.","logo":"@type":"ImageObject","url":"https://www.wikimedia.org/static/images/wmf-hor-googpub.png","datePublished":"2016-11-05T19:32:20Z","dateModified":"2019-02-06T06:48:45Z"(RLQ=window.RLQ||[]).push(function()mw.config.set("wgBackendResponseTime":118,"wgHostname":"mw1275"););