simple calculator

308 views
Skip to first unread message

Tymoteusz Moryto

unread,
Aug 16, 2018, 7:30:52 AM8/16/18
to lci-general
Hello.
I've made a simple calculator in LOLCODE.
Here's the link

leyarotheconquerer

unread,
Aug 16, 2018, 7:50:31 PM8/16/18
to lci-general
Nice!  I like it.

Looking at your code, I began wondering if it could use Bukkits to store the internationalization text (basically have an array of arrays, where each inner array is a list of phrases for that language). I got it working in my fork, but I ran into an unexpected problem with multi-level arrays.

It looks like lci uses a bad order of operations when evaluating code like this:

HAI 1.4

BTW Initialize an array of arrays: [ { phrase: "Test phrase" } ]
I HAS A array ITZ A BUKKIT
array HAS A SRS 0 ITZ A BUKKIT
array'Z SRS 0 HAS A phrase ITZ "Test phrase"

BTW This attempt to dereference the first element works: array[0]['phrase']
VISIBLE array'Z SRS 0'Z phrase

BTW But this attempt does not: array[index]['phrase']
I HAS A index ITZ 0
VISIBLE array'Z SRS index'Z phrase
BTW This errors out, complaining that 'index' is not an array

BTW My current work around is to store the intermediate reference: inter = array[0]; inter['phrase']
I HAS A intermediate ITZ array'Z SRS index
VISIBLE intermediate'Z phrase

KTHXBYE

If anyone knows how to do this without using an intermediate variable, that would be great.

Thanks.

Justin Meza

unread,
Aug 16, 2018, 8:24:37 PM8/16/18
to lci-g...@googlegroups.com
This is pretty awesome, Tymoteusz! Great work.

I'd need to go back to the BUKKIT definition to see how order of operation is defined, but I may have gotten it wrong (if so, someone should open up a bug for this).

- Justin

--
You received this message because you are subscribed to the Google Groups "lci-general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lci-general...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

lar...@sasktel.net

unread,
Sep 13, 2019, 1:16:09 PM9/13/19
to lci-general
Love it! I am new (this morning) to LOLCODE, and I haven't laughed this hard for years.

Anyway, I thought I'd make the output more LOLCATish. I only did the Emglish part.
Not sure how to use git, so I hope it's OK to paste the English portion here.

HAI 1.4

BTW special characters sadly not supported

I HAS A JEDEN
I HAS A DWA
I HAS A EX
I HAS A LNG
VISIBLE "Chooz langwich."
VISIBLE "1. Inglush"
VISIBLE "2. polski"
GIMMEH LNG
LNG, WTF?
  OMG "1" BTW English
    VISIBLE ":)Welcom 2 calculator. :)Entr furst numbr:"
    GIMMEH JEDEN
    VISIBLE " :)Entr secund number:"
      GIMMEH DWA
    JEDEN IS NOW A NUMBAR
    DWA IS NOW A NUMBAR
    BOTH SAEM DWA AN 0.0, O RLY?
      YA RLY
        VISIBLE ":)Chooz yr operashun: :)1. Sum dem:)2. Diff dem :)3. Multuply dem :)4. Div dem"
        GIMMEH EX
        EX, WTF?
          OMG "1"
            VISIBLE SUM OF JEDEN AN DWA
            GTFO
          OMG "2"
            VISIBLE DIFF OF JEDEN AN DWA
            GTFO
          OMG "3"
            VISIBLE PRODUKT OF JEDEN AN DWA
            GTFO
          OMG "4"
            VISIBLE "U not smart - zero into numbr is no gud"
            GTFO
          OMGWTF
            VISIBLE "Choose teh operashun thru enterin numbr i gaev u."
            GTFO
          OIC
      NO WAI
        VISIBLE ":)Choose yr operation: :)1. Sum dem:)2. Diff dem :)3. Multuply dem :)4. Div dem"
        GIMMEH EX
        EX, WTF?
          OMG "1"
            VISIBLE SUM OF JEDEN AN DWA
            GTFO
          OMG "2"
            VISIBLE DIFF OF JEDEN AN DWA
            GTFO
          OMG "3"
            VISIBLE PRODUKT OF JEDEN AN DWA
            GTFO
          OMG "4"
            VISIBLE QUOSHUNT OF JEDEN AN DWA
            GTFO
          OMGWTF
            VISIBLE "Chooz teh operashun thru enterin a numbr I gaev u."
            GTFO
          OIC
    OIC
    GTFO

Reply all
Reply to author
Forward
0 new messages