Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
fuss:lolcode [2015/02/09 19:22] officefuss:lolcode [2022/04/19 08:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== About ======
 +
 +The API is compatible with the LOLCODE Specification 1.2. The functions have to be used between the opening and closing program blocks. For example:
 +
 +<code>
 +HAI 1.2
 +
 +[... insert function ...]
 +
 +  I HAS A VAR ITZ 4
 +  VISIBLE SMOOSH "Factorial: " AN I IZ WAS_FAK YR VAR MKAY
 +  
 +KTHXBYE
 +</code>
 +
 +will print out the factorial of ''4'' provided that the ''WAS_FAK'' function is inserted into the placeholder (this is because functions in LOLCODE cannot live outside of the ''HAI''/''KTHXBYE'' code-blocks.
 +
 +====== Numerical Inequalities ======
 +
 +A set of functions that perform various numerical inequalities following LaTeX syntax: ''LT'' ($<$), ''LE'' ($\le$), ''GT'' ($>$) and ''GE'' ($\ge$).
 +
 +===== Less Than ========
 +
 +<code lolcode>
 +OBTW  Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3  TLDR
 +HOW IZ I LT YR LEFT AN YR RIGHT
 +    FOUND YR DIFFRINT LEFT AN BIGGR OF LEFT AN RIGHT
 +IF U SAY SO
 +</code>
 +
 +===== Greater Than =====
 +<code lolcode>
 +OBTW  Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3  TLDR
 +HOW IZ I GT YR LEFT AN YR RIGHT
 +    FOUND YR DIFFRINT LEFT AN SMALLR OF LEFT AN RIGHT
 +IF U SAY SO
 +</code>
 +
 +===== Less or Equal Than =====
 +
 +<code lolcode>
 +OBTW  Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3  TLDR
 +HOW IZ I LE YR LEFT AN YR RIGHT
 +    BOTH SAEM LEFT AN SMALLR OF LEFT AN RIGHT
 +IF U SAY SO
 +</code>
 +
 +===== Greater or Equal Than =====
 +
 +<code lolcode>
 +OBTW  Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3  TLDR
 +HOW IZ I GE YR LEFT AN YR RIGHT
 +    FOUND YR BOTH SAEM LEFT AN BIGGR OF LEFT AN RIGHT
 +IF U SAY SO
 +</code>
 +
 +
 +
 +====== Raise Base to Exponent ======
 +
 +<code lolcode>
 +OBTW  Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3  TLDR
 +HOW IZ I WAS_RAIZ YR FOOT AN YR PAW
 +  I HAS A BASE ITZ FOOT
 +  IM IN YR LOOP UPPIN YR STUFF WILE DIFFRINT STUFF AN PAW
 +    FOOT R PRODUKT OF FOOT AN BASE
 +  IM OUTTA YR LOOP
 +  FOUND YR QUOSHUNT OF FOOT AN BASE
 +IF U SAY SO
 +</code>
 +
 +====== Factorial ======
 +
 +<code lolcode>
 +OBTW  Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3  TLDR
 +HOW IZ I WAS_FAK YR TAIL
 +    TAIL, WTF?
 +        OMG 0
 +          FOUND YR 1
 +        OMG 1
 +          FOUND YR TAIL
 +    OIC
 +    FOUND YR PRODUKT OF TAIL AN I IZ WAS_FAK YR DIFF OF TAIL AN 1 MKAY 
 +IF U SAY SO
 +</code>
 +
 +====== Random Number Generator ======
 +
 +This is a Lehmer random number generator,
 +
 +$$
 +X_{k+1} = g*X_{k} \mod{n}
 +$$
 +
 +using the ZX Spectrum Fermat prime vectors where $g=75$ and $n=65537$.
 +
 +<code lolcode>
 +OBTW  Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3  TLDR
 +I HAS A COUNTER ITZ 1
 +HOW IZ I WAS_MESS YR NUMBER
 +    I HAS A THING ITZ MAEK NUMBER A NUMBAR
 +    IM IN YR LOOP UPPIN YR ROUNDS WILE DIFFRINT ROUNDS AN NUMBER
 +        THING R MOD OF PRODUKT OF 75 AN SUM OF THING AN COUNTER AN 65537
 +        COUNTER R SUM OF COUNTER AN 1
 +    IM OUTTA YR LOOP
 +    FOUND YR MOD OF THING AN NUMBER
 +IF U SAY SO
 +</code>
 +
 +The algorithm will generate numbers in the interval $[0,65537)$ (larger if a different Fermat prime is chosen for $g$). The function takes a parameter an upper bound ''NUMBER'' and can be called using:
 +
 +<code lolcode>
 +VISIBLE I IZ WAS_MESS YR 100 MKAY
 +</code>
 +
 +which will generate a random number in the interval $[0, 100)$.
 +
 +The following plot:
 +
 +<plot>
 +set terminal png size 900,256
 +set xlabel "Draw"
 +set ylabel "Value"
 +plot "-" using ($1*5):2 with lines title ""
 +1 94
 +2 2
 +3 10
 +4 55
 +5 63
 +6 71
 +7 79
 +8 24
 +9 32
 +10 40
 +11 48
 +12 56
 +13 1
 +14 9
 +15 17
 +16 25
 +17 33
 +18 78
 +19 86
 +20 94
 +21 2
 +22 47
 +23 55
 +24 63
 +25 71
 +26 79
 +27 24
 +28 32
 +29 40
 +30 48
 +31 93
 +32 1
 +33 9
 +34 17
 +35 25
 +36 70
 +37 78
 +38 86
 +39 94
 +40 2
 +41 47
 +42 55
 +43 63
 +44 71
 +45 16
 +46 24
 +47 32
 +48 40
 +49 48
 +50 93
 +51 1
 +52 9
 +53 17
 +54 25
 +55 70
 +56 78
 +57 86
 +58 94
 +59 39
 +60 47
 +61 55
 +62 63
 +63 71
 +64 16
 +65 24
 +66 32
 +67 40
 +68 85
 +69 93
 +70 1
 +71 9
 +72 17
 +73 62
 +74 70
 +75 78
 +76 86
 +77 94
 +78 39
 +79 47
 +80 55
 +81 63
 +82 8
 +83 16
 +84 24
 +85 32
 +86 40
 +87 85
 +88 93
 +89 1
 +90 9
 +91 17
 +92 62
 +93 70
 +94 78
 +95 86
 +96 31
 +97 39
 +98 47
 +99 55
 +100 63
 +101 8
 +102 16
 +103 24
 +104 32
 +105 77
 +106 85
 +107 93
 +108 1
 +109 9
 +110 54
 +111 62
 +112 70
 +113 78
 +114 86
 +115 31
 +116 39
 +117 47
 +118 55
 +119 0
 +120 8
 +121 16
 +122 24
 +123 32
 +124 77
 +125 85
 +126 93
 +127 1
 +128 46
 +129 54
 +130 62
 +131 70
 +132 78
 +133 23
 +134 31
 +135 39
 +136 47
 +137 55
 +138 0
 +139 8
 +140 16
 +141 24
 +142 69
 +143 77
 +144 85
 +145 93
 +146 1
 +147 46
 +148 54
 +149 62
 +150 70
 +151 78
 +152 23
 +153 31
 +154 39
 +155 47
 +156 92
 +157 0
 +158 8
 +159 16
 +160 24
 +161 69
 +162 77
 +163 85
 +164 93
 +165 38
 +166 46
 +167 54
 +168 62
 +169 70
 +170 15
 +171 23
 +172 31
 +173 39
 +174 47
 +175 92
 +176 0
 +177 8
 +178 16
 +179 61
 +180 69
 +181 77
 +182 85
 +183 93
 +184 38
 +185 46
 +186 54
 +187 62
 +188 7
 +189 15
 +190 23
 +191 31
 +192 39
 +193 84
 +194 92
 +195 0
 +196 8
 +197 16
 +198 61
 +199 69
 +200 77
 +201 85
 +202 30
 +203 38
 +204 46
 +205 54
 +206 62
 +207 7
 +208 15
 +209 23
 +210 31
 +211 39
 +212 84
 +213 92
 +214 0
 +215 8
 +216 53
 +217 61
 +218 69
 +219 77
 +220 85
 +221 30
 +222 38
 +223 46
 +224 54
 +225 99
 +226 7
 +227 15
 +228 23
 +229 31
 +230 76
 +231 84
 +232 92
 +233 0
 +234 8
 +235 53
 +236 61
 +237 69
 +238 77
 +239 22
 +240 30
 +241 38
 +242 46
 +243 54
 +244 99
 +245 7
 +246 15
 +247 23
 +248 31
 +249 76
 +250 84
 +251 92
 +252 0
 +253 45
 +254 53
 +255 61
 +256 69
 +257 77
 +258 22
 +259 30
 +260 38
 +261 46
 +262 91
 +263 99
 +264 7
 +265 15
 +266 23
 +267 68
 +268 76
 +269 84
 +270 92
 +271 0
 +272 45
 +273 53
 +274 61
 +275 69
 +276 14
 +277 22
 +278 30
 +279 38
 +280 46
 +281 91
 +282 99
 +283 7
 +284 15
 +285 60
 +286 68
 +287 76
 +288 84
 +289 92
 +290 37
 +291 45
 +292 53
 +293 61
 +294 69
 +295 14
 +296 22
 +297 30
 +298 38
 +299 83
 +300 91
 +301 99
 +302 7
 +303 15
 +304 60
 +305 68
 +306 76
 +307 84
 +308 92
 +309 37
 +310 45
 +311 53
 +312 61
 +313 6
 +314 14
 +315 22
 +316 30
 +317 38
 +318 83
 +319 91
 +320 99
 +321 7
 +322 52
 +323 60
 +324 68
 +325 76
 +326 84
 +327 29
 +328 37
 +329 45
 +330 53
 +331 61
 +332 6
 +333 14
 +334 22
 +335 30
 +336 75
 +337 83
 +338 91
 +339 99
 +340 7
 +341 52
 +342 60
 +343 68
 +344 76
 +345 21
 +346 29
 +347 37
 +348 45
 +349 53
 +350 98
 +351 6
 +352 14
 +353 22
 +354 30
 +355 75
 +356 83
 +357 91
 +358 99
 +359 44
 +360 52
 +361 60
 +362 68
 +363 76
 +364 21
 +365 29
 +366 37
 +367 45
 +368 53
 +369 98
 +370 6
 +371 14
 +372 22
 +373 67
 +374 75
 +375 83
 +376 91
 +377 99
 +378 44
 +379 52
 +380 60
 +381 68
 +382 13
 +383 21
 +384 29
 +385 37
 +386 45
 +387 90
 +388 98
 +389 6
 +390 14
 +391 22
 +392 67
 +393 75
 +394 83
 +395 91
 +396 36
 +397 44
 +398 52
 +399 60
 +400 68
 +401 13
 +402 21
 +403 29
 +404 37
 +405 45
 +406 90
 +407 98
 +408 6
 +409 14
 +410 59
 +411 67
 +412 75
 +413 83
 +414 91
 +415 36
 +416 44
 +417 52
 +418 60
 +419 5
 +420 13
 +421 21
 +422 29
 +423 37
 +424 82
 +425 90
 +426 98
 +427 6
 +428 14
 +429 59
 +430 67
 +431 75
 +432 83
 +433 28
 +434 36
 +435 44
 +436 52
 +437 60
 +438 5
 +439 13
 +440 21
 +441 29
 +442 74
 +443 82
 +444 90
 +445 98
 +446 6
 +447 51
 +448 59
 +449 67
 +450 75
 +451 83
 +452 28
 +453 36
 +454 44
 +455 52
 +456 97
 +457 5
 +458 13
 +459 21
 +460 29
 +461 74
 +462 82
 +463 90
 +464 98
 +465 6
 +466 51
 +467 59
 +468 67
 +469 75
 +470 20
 +471 28
 +472 36
 +473 44
 +474 52
 +475 97
 +476 5
 +477 13
 +478 21
 +479 66
 +480 74
 +481 82
 +482 90
 +483 98
 +484 43
 +485 51
 +486 59
 +487 67
 +488 75
 +489 20
 +490 28
 +491 36
 +492 44
 +493 89
 +494 97
 +495 5
 +496 13
 +497 21
 +498 66
 +499 74
 +500 82
 +501 90
 +502 35
 +503 43
 +504 51
 +505 59
 +506 67
 +507 12
 +508 20
 +509 28
 +510 36
 +511 44
 +512 89
 +513 97
 +514 5
 +515 13
 +516 58
 +517 66
 +518 74
 +519 82
 +520 90
 +521 35
 +522 43
 +523 51
 +524 59
 +525 67
 +526 12
 +527 20
 +528 28
 +529 36
 +530 81
 +531 89
 +532 97
 +533 5
 +534 13
 +535 58
 +536 66
 +537 74
 +538 82
 +539 27
 +540 35
 +541 43
 +542 51
 +543 59
 +544 4
 +545 12
 +546 20
 +547 28
 +548 36
 +549 81
 +550 89
 +551 97
 +552 5
 +553 50
 +554 58
 +555 66
 +556 74
 +557 82
 +558 27
 +559 35
 +560 43
 +561 51
 +562 59
 +563 4
 +564 12
 +565 20
 +566 28
 +567 73
 +568 81
 +569 89
 +570 97
 +571 5
 +572 50
 +573 58
 +574 66
 +575 74
 +576 19
 +577 27
 +578 35
 +579 43
 +580 51
 +581 96
 +582 4
 +583 12
 +584 20
 +585 28
 +586 73
 +587 81
 +588 89
 +589 97
 +590 42
 +591 50
 +592 58
 +593 66
 +594 74
 +595 19
 +596 27
 +597 35
 +598 43
 +599 88
 +600 96
 +601 4
 +602 12
 +603 20
 +604 65
 +605 73
 +606 81
 +607 89
 +608 97
 +609 42
 +610 50
 +611 58
 +612 66
 +613 11
 +614 19
 +615 27
 +616 35
 +617 43
 +618 88
 +619 96
 +620 4
 +621 12
 +622 20
 +623 65
 +624 73
 +625 81
 +626 89
 +627 34
 +628 42
 +629 50
 +630 58
 +631 66
 +632 11
 +633 19
 +634 27
 +635 35
 +636 80
 +637 88
 +638 96
 +639 4
 +640 12
 +641 57
 +642 65
 +643 73
 +644 81
 +645 89
 +646 34
 +647 42
 +648 50
 +649 58
 +650 3
 +651 11
 +652 19
 +653 27
 +654 35
 +655 80
 +656 88
 +657 96
 +658 4
 +659 12
 +660 57
 +661 65
 +662 73
 +663 81
 +664 26
 +665 34
 +666 42
 +667 50
 +668 58
 +669 3
 +670 11
 +671 19
 +672 27
 +673 72
 +674 80
 +675 88
 +676 96
 +677 4
 +678 49
 +679 57
 +680 65
 +681 73
 +682 81
 +683 26
 +684 34
 +685 42
 +686 50
 +687 95
 +688 3
 +689 11
 +690 19
 +691 27
 +692 72
 +693 80
 +694 88
 +695 96
 +696 41
 +697 49
 +698 57
 +699 65
 +700 73
 +701 18
 +702 26
 +703 34
 +704 42
 +705 50
 +706 95
 +707 3
 +708 11
 +709 19
 +710 64
 +711 72
 +712 80
 +713 88
 +714 96
 +715 41
 +716 49
 +717 57
 +718 65
 +719 73
 +720 18
 +721 26
 +722 34
 +723 42
 +724 87
 +725 95
 +726 3
 +727 11
 +728 19
 +729 64
 +730 72
 +731 80
 +732 88
 +733 33
 +734 41
 +735 49
 +736 57
 +737 65
 +738 10
 +739 18
 +740 26
 +741 34
 +742 42
 +743 87
 +744 95
 +745 3
 +746 11
 +747 56
 +748 64
 +749 72
 +750 80
 +751 88
 +752 33
 +753 41
 +754 49
 +755 57
 +756 2
 +757 10
 +758 18
 +759 26
 +760 34
 +761 79
 +762 87
 +763 95
 +764 3
 +765 11
 +766 56
 +767 64
 +768 72
 +769 80
 +770 25
 +771 33
 +772 41
 +773 49
 +774 57
 +775 2
 +776 10
 +777 18
 +778 26
 +779 34
 +780 79
 +781 87
 +782 95
 +783 3
 +784 48
 +785 56
 +786 64
 +787 72
 +788 80
 +789 25
 +790 33
 +791 41
 +792 49
 +793 94
 +794 2
 +795 10
 +796 18
 +797 26
 +798 71
 +799 79
 +800 87
 +801 95
 +802 3
 +803 48
 +804 56
 +805 64
 +806 72
 +807 17
 +808 25
 +809 33
 +810 41
 +811 49
 +812 94
 +813 2
 +814 10
 +815 18
 +816 26
 +817 71
 +818 79
 +819 87
 +820 95
 +821 40
 +822 48
 +823 56
 +824 64
 +825 72
 +826 17
 +827 25
 +828 33
 +829 41
 +830 86
 +831 94
 +832 2
 +833 10
 +834 18
 +835 63
 +836 71
 +837 79
 +838 87
 +839 95
 +840 40
 +841 48
 +842 56
 +843 64
 +844 9
 +845 17
 +846 25
 +847 33
 +848 41
 +849 86
 +850 94
 +851 2
 +852 10
 +853 55
 +854 63
 +855 71
 +856 79
 +857 87
 +858 32
 +859 40
 +860 48
 +861 56
 +862 64
 +863 9
 +864 17
 +865 25
 +866 33
 +867 78
 +868 86
 +869 94
 +870 2
 +871 10
 +872 55
 +873 63
 +874 71
 +875 79
 +876 87
 +877 32
 +878 40
 +879 48
 +880 56
 +881 1
 +882 9
 +883 17
 +884 25
 +885 33
 +886 78
 +887 86
 +888 94
 +889 2
 +890 47
 +891 55
 +892 63
 +893 71
 +894 79
 +895 24
 +896 32
 +897 40
 +898 48
 +899 56
 +900 1
 +901 9
 +902 17
 +903 25
 +904 70
 +905 78
 +906 86
 +907 94
 +908 2
 +909 47
 +910 55
 +911 63
 +912 71
 +913 16
 +914 24
 +915 32
 +916 40
 +917 48
 +918 93
 +919 1
 +920 9
 +921 17
 +922 25
 +923 70
 +924 78
 +925 86
 +926 94
 +927 39
 +928 47
 +929 55
 +930 63
 +931 71
 +932 16
 +933 24
 +934 32
 +935 40
 +936 48
 +937 93
 +938 1
 +939 9
 +940 17
 +941 62
 +942 70
 +943 78
 +944 86
 +945 94
 +946 39
 +947 47
 +948 55
 +949 63
 +950 8
 +951 16
 +952 24
 +953 32
 +954 40
 +955 85
 +956 93
 +957 1
 +958 9
 +959 17
 +960 62
 +961 70
 +962 78
 +963 86
 +964 31
 +965 39
 +966 47
 +967 55
 +968 63
 +969 8
 +970 16
 +971 24
 +972 32
 +973 40
 +974 85
 +975 93
 +976 1
 +977 9
 +978 54
 +979 62
 +980 70
 +981 78
 +982 86
 +983 31
 +984 39
 +985 47
 +986 55
 +987 0
 +988 8
 +989 16
 +990 24
 +991 32
 +992 77
 +993 85
 +994 93
 +995 1
 +996 9
 +997 54
 +998 62
 +999 70
 +1000 78
 +
 +</plot>
 +
 +is the result of by drawing $10^3$ numbers in the interval $[0, 100)$ using:
 +
 +<code lolcode>
 +IM IN YR LOOP UPPIN YR DRAWS WILE DIFFRINT DRAWS AN 1000
 +    VISIBLE I IZ WAS_MESS YR 100 MKAY
 +IM OUTTA YR LOOP
 +</code>
 +
 +====== Fibonacci Number Generator ======
 +
 +The ''WAS_FIB'' function prints out the first ''ROUNDS'' number of Fibonacci numbers starting with the initialisation vectors (either ''0'' and ''1'' or ''1'' and ''1'') passed to the function as ''FIRST'' and ''SECOND''.
 +
 +<code lolcode>
 +OBTW  Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3  TLDR
 +HOW IZ I WAS_FIB YR ROUNDS AN YR FIRST AN YR SECOND
 +    DIFFRINT ROUNDS AN SMALLR OF ROUNDS AN 0, O RLY?
 +        YA RLY,
 +            VISIBLE FIRST
 +            FOUND YR I IZ WAS_FIB YR DIFF OF ROUNDS AN 1 AN YR SECOND AN YR SUM OF FIRST AN SECOND MKAY
 +        NO WAI,
 +            GTFO
 +    OIC
 +IF U SAY SO
 +</code>
 +
 +An example call is:
 +<code lolcode>
 +I HAS A ROUNDS ITZ 10
 +I HAS A FIRST ITZ 0
 +I HAS A SECOND ITZ 1
 +I IZ WAS_FIB YR ROUNDS AN YR FIRST AN YR SECOND MKAY
 +</code>
 +
 +which prints out:
 +<code lolcode>
 +0
 +1
 +1
 +2
 +3
 +5
 +8
 +13
 +21
 +34
 +</code>
 +
 +Note that the edge-cases where the function is passed a ''ROUNDS'' number smaller than the initialisation vector are respected by ''WAS_FIB''.
  

fuss/lolcode.1423509737.txt.bz2 · Last modified: 2015/02/09 19:22 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.