Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Wnt/Expression
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
--- this began long ago when a first test program for the Mandelbrot set went pear-shaped local p={} function chunk(text) local text=mw.ustring.gsub(text,"(%d%s*)E(%s*[%d%+%-])","%1 E %2") -- force space around E notation to avoid going nuts later local debuglog="" local chunks={type={}} local prowl=mw.ustring.gmatch(text,"(%S+)") local firstbit local num=1 local op=2 local var=3 local warning=4 local defs={num={"^([%d%.]*)(.*)$"},op={"^(E?)(.*)$","^([%(%)%*%+%-%?%%/!^]?)(.*)$"},var={"^(%a*)(.*)$"}} t=prowl() while t do local ot=t for i,j in pairs(defs) do for _,v in pairs(j) do firstbit,t=mw.ustring.match(t,v) debuglog=debuglog.."<"..tostring(firstbit)..","..tostring(t)..">"..tostring(i).."i"..tostring(j).."j"..tostring(t).."t"..tostring(v).."v" assert(t,debuglog) -- should always deliver a null string even if the target isn't there if firstbit ~= "" then table.insert(chunks,firstbit) table.insert(chunks.type,i) end end end if t==ot then firstbit,t=mw.ustring.match(t,"^(.)(.*)$") table.insert(chunks,'ignored:'..firstbit) table.insert(chunks.type,warning) end if t=="" then t=prowl() end -- if you run out of bits between spaces, pull a new interspace bit. end return chunks end function p.main(frame) local args=frame.args or {} local parent=frame.getParent(frame) or {} local pargs=parent.args or {} local expr=args.expr or pargs.expr or "" -- (Handle nothing in with nothing out?) local chunks=chunk(expr) return #chunks,"types"..table.concat(chunks.type,",").."values"..table.concat(chunks,",") -- check 1: getting the input sorted out into chunks end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Wnt/Expression/doc
(
edit
)