What Does Hash Mean in Lua Programming

Mukul Latiyan
Updated on 19-Jul-2021 11:28:42

879 Views

The unary operator # is known as the Length operator in Lua. It is used almost everywhere in Lua. By everywhere, I meant that anywhere we would require to calculate the length of the any string or can also be used in tables also, but when it comes to table, it is generally not preferred to use the # operator as it doesn’t calculate the number of elements present inside the table.Let’s explore different examples of the length operator to understand how we can make use of it.ExampleConsider the example shown below − Live Demoprint(#"abcdefg") print(#{"a", "b", "c", 77})Output7 4In the ... Read More

Important Scientific Libraries Used in Lua Programming

Mukul Latiyan
Updated on 19-Jul-2021 11:25:40

405 Views

While we know that Lua does a great job when we want to use it as an embedded language, it can also exceed its basic uses and can be used in extreme cases such as Machine Learning and statistical analysis.There are many scientific libraries that are present in the market for this particular case of making more out of Lua. Let’s explore what these libraries are and what they do.The first name that comes to my mind when talking about Lua and machine learning in the same sentence is of the Torch project. The torch project is a scientific computing ... Read More

What Are Closures in Lua Programming

Mukul Latiyan
Updated on 19-Jul-2021 11:23:46

1K+ Views

In Lua, any function is a closure. In a narrower sense, a closure is an anonymous function like the returned function in your example.Closures are first-class: they can be assigned to variables, passed to functions and returned from them. They can be both keys and values in Lua tables.Unlike C++ or PHP, closures in Lua have access to all variables in local scope— upvalues with no need to declare upvalues explicitly. Upvalues survive when code execution leaves the block where they were set.Now that we know what a closure is and why it is useful, let’s take an example and ... Read More

The Index Metamethod in Lua Programming

Mukul Latiyan
Updated on 19-Jul-2021 11:20:29

2K+ Views

Whenever we try to access a field that hasn’t been declared in a table in Lua, the answer we get is nil. While this is true, but the reason for it is that when such access happens, the interpreter triggers a search for an __index metamethod and if it doesn’t find any method named __index, then we get nil as an answer; else we will get whatever the value of the field is set in the __index metamethod.We can explicitly put in the __index method in a table and provide it the named values that we want it to return ... Read More

Table Unpack Function in Lua Programming

Mukul Latiyan
Updated on 19-Jul-2021 11:17:40

17K+ Views

When we want to return multiple values from a table, we make use of the table.unpack() function. It takes a list and returns multiple values.Syntaxtable.unpack{x, y, z, ....}ExampleThe table.unpack() function provides us with all the values that are passed to it as an argument, but we can also specify which value we want by following the example shown below − Live Demoa, b = table.unpack{1, 2, 3} print(a, b)In the above example, even though the table.unpack() function contains different values, namely 1, 2 and 3, we only are storing the first two values, i.e., a and b and the value 3 ... Read More

Table Pack Function in Lua Programming

Mukul Latiyan
Updated on 19-Jul-2021 11:16:16

6K+ Views

When we want to return a table as a result from multiple values passed into a function, then we make use of the table.pack() function. The table.pack() function is a variadic function.Syntaxtable.pack(x, y, z, ....)ExampleThe table.pack() function provides a table formed with all the values that are passed to it as an argument, consider the example shown below − Live Demoa = table.pack(1, 2, 3) print(a) print(a.n)In the above example, we passed three numbers to the table.pack() function as an argument and then we are printing the returned value, i.e., which will hold the address of the table that contains the ... Read More

Differences Between Copyright and Patent

Nagasravan Tamma
Updated on 19-Jul-2021 11:11:11

897 Views

In simple words a patent is nothing but securing an invention and copyrights are nothing but securing original ideas. Both are governed by different rules and regulationsCopyrightsThe main objective of copyright is to secure the original idea or expression of idea of an artist. An artist's work can be a computer program, music, song, movie or any original work. Example − a book written by a cook.Others can't reproduce the same book or without permission of the book but however they can use the recipes used in it. To get copyrights, the artist first has to register with the respective ... Read More

Differentiate Between Trademark and Copyright

Nagasravan Tamma
Updated on 19-Jul-2021 11:09:46

645 Views

Copyright and trademark comes under intellectual property. Although both look the same, sometimes it creates confusion in the readers' mind. Let us give brief idea about copyright and trademark and difference between themCopyrightThe main objective of copyright is to protect the artist's original work. Work may be a photo, book, painting, software code; article etc. copyright gives the owner a right to reproduce their work or profit off their underlying work.The principle involved is pretty simple "if you create something new or original work, you have to choose what to do". To get the copyrights you have to register first ... Read More

Types of Intellectual Properties Explained

Nagasravan Tamma
Updated on 19-Jul-2021 11:08:50

567 Views

The term property means an individual or an organization owns it and it is protected by means of law. Intellectual properties are intangible assets of a business or a person. It can be a book, article in a magazine, a new design etc. which comes under intellectual properties.TypesThe types of intellectual properties are explained follows −PatentsA patent protects innovative ideas. It gives special rights to the respective owner/organization in making, selling and using the product or service period. A government authority or license conferring a right will be issued. An individual or an organization will approach the patent authority, submit ... Read More

Intellectual Property Rights Explained

Nagasravan Tamma
Updated on 19-Jul-2021 11:08:05

589 Views

Intellectual property rights give right to the persons over their inventions, literary works, etc. Rights for their creations have a timeframe. The right for protection is outlined in the universal declaration of human rights (Article 27).Importance of intellectual property was recognized in the Paris convention for protection of industrial property in 1883 and Berne convention for the protection of literary and artistic works in 1886. The World intellectual property organization administers both these treaties.Need for intellectual property rights are explained below −To encourage innovations.To increase economic growth.To safeguard creators' rights.Promote innovations.Transfer of technology.Safety of intellectual propertiesAn employee needs to understand ... Read More

Advertisements