Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

48
LINES

< > BotCompany Repo | #1007987 // Thought Bubble 1 prelude 7: Adding minus and division [WORKS]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (10807L/74K).

!7

// We can parse and evaluate ALL THIS:

sS stuffToParse = [[
  1
  1 - 2
  1 - 2 - 3
  1 - (2 - 3)
  -5 - 4
  (4 - 3) - 2
  100 / (10 * 2)
  100 / 10 / 10
]];

sS concepts = [[
  // ...just by giving a few parsing concepts (w/increasing binding power):
  
  ["jcnbmtmfzktxhzyf", "X + Y"],
  ["jxcubqjtqykhfvyo", "X - Y", "as in minus"],
  ["erdirznfvsrbtfns", "X / Y", "division"],
  ["bwqhmnorjpyomdbv", "X * Y", "multiplication"],
  
  // ...and a bit of meta-level stuff:
  ["mcoswmplpqlieruo", "(X)"],
  ["olphazqzxxnvtjcx", "X evaluates through standard function Y."],
  ["wwaprwlmqzqeaikp", "A leaf satisfying standard function X evaluates through standard function Y."],
  ["hkihrqgdlkdayxzn", "X is just bracketing."],
]];

// ...and finally linking everything together by relating concepts
// to JavaX standard functions.

sS statements = [[
  olphazqzxxnvtjcx jcnbmtmfzktxhzyf "plus"
  olphazqzxxnvtjcx jxcubqjtqykhfvyo "minus"
  olphazqzxxnvtjcx bwqhmnorjpyomdbv "multiply"
  olphazqzxxnvtjcx erdirznfvsrbtfns "divide"
  hkihrqgdlkdayxzn mcoswmplpqlieruo
  wwaprwlmqzqeaikp "isInteger" "bigint"
]];

// The rest is boilerplate.

p-tt {
  centerHigherConsole();
  testLispEval(concepts, statements, stuffToParse);
}

Author comment

Began life as a copy of #1007981

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, wtqryiryparv

No comments. add comment

Snippet ID: #1007987
Snippet name: Thought Bubble 1 prelude 7: Adding minus and division [WORKS]
Eternal ID of this version: #1007987/18
Text MD5: dd82a4f232bff3cebf58e3b636a2d69e
Transpilation MD5: 1b59158b8342fa666e808e8b013213e8
Author: stefan
Category: javax / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-18 04:08:29
Source code size: 1276 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 667 / 1823
Version history: 17 change(s)
Referenced in: [show references]