LingDong- / wax

A tiny programming language that transpiles to C, C++, Java, TypeScript, Python, C#, Swift, Lua and WebAssembly 🚀
https://waxc.netlify.app/
MIT License
793 stars 45 forks source link

how to prepend string? #29

Closed WingDust closed 1 year ago

WingDust commented 1 year ago
(func bothS (param input str) (result str)

    (return   (<< input "'") )
)
(func main (result int)
    (print (call bothS "aa"))
    (return 0)  
)

I want to ouput 'aa' ,how to do ?

jacoblister commented 1 year ago

It just appends to the string one string at a time. So you can do

(func bothS (param input str) (result str)
    (let res str (alloc str))
    (<< res "'")
    (<< res input)
    (<< res "'")

    (return res)
)
(func main (result int)
    (print (call bothS "aa"))
    (return 0)  
)