Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Creating habits v3, Lua
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
--[[ Creating habits v3 Lua ]]-- local array1 = {"tset1", "26", "jsdfl"} -- Creates an array of strings -- local function test(x) if x ~= nil then -- Checks if x isn't nil -- table.insert(array1, tostring(x)) -- If x isn't nil, insert a string -- end local str = ""; -- Creates an empty string -- for _,v in pairs (array1) do -- Goes thorugh array1 and inserts them into "str" -- str = str.. " "..tostring(v) -- Inserts "v" (What's in the array) into "str" -- end if x ~= nil then table.remove(array1, #array1) -- Removes the inserted string (if there was one) -- end return str -- Returns the completed "str" -- end print(test(56)) -- Runs and prints the function -- 56 gets inserted into the array, then gets removed -- print("\n".. test()) -- Creates a new line and runs the function again w/o inserting something into the table --
[
+
]
Show input
Absolute running time: 0.07 sec, cpu time: 0.01 sec, memory peak: 3 Mb, absolute service time: 0,08 sec
edit mode
|
history
|
discussion
tset1 26 jsdfl 56 tset1 26 jsdfl