Discussion:
Apologies for bad formatting: lecture slides etc.
Luke
2018-11-05 05:43:02 UTC
Permalink
Hi,

I'm not getting some of the examples in the slides

t = table.pack(1, nil, 3)
for i = 1, t.n do
print(t[i])
end

Does t.n give the value of' 3?

for k, v in pairs(tab) do

What does in do in this line of code?

function derivative(f, dx)
dx = dx or 1e - 4
return
function (x)
return(f(x + dx) - f(x)) / dx
end
end

I get an error message running this, from the lecture'"more on function".

Do resources like this mean I might one day use CSound in lua
interpreted by C++ without knowing C?

github.com/csound/csoundAPI_examples/tree/master/lua

Cheers,
Luke
Luke
2018-11-07 02:29:44 UTC
Permalink
More from the documentation... thanks for any help!

function map(f)
return function (l)
local nl = {}
for i, x in ipairs(l) do
nl[i] = f(x)
end
return nl
end
end
square = map(function (x) return x * x end)
print(table.unpack(square{ 1, 5, 9 }))

--[[
I believe that, because the definition does not begin with function, square
is an anonymous function; it returns a value and is defined in an
expression. So, I start with the table { 1, 5, 9 }. This is the argument to
the square function. I'm guessing that the map function is called by
square. But how / why does map get the table, when map only has one
parameter, a function, and the table is not assigned to a variable? And how
/ why does map return a table value, as it seems to want to return a
function?

]]
Luke
2018-11-07 02:48:03 UTC
Permalink
Or perhaps square is not the higher order function: map is its argument not
the table?

Or is square not a function, even-though it is defined by something (map)
that returns a function, as it is not defined with 'function'?
Post by Luke
More from the documentation... thanks for any help!
function map(f)
return function (l)
local nl = {}
for i, x in ipairs(l) do
nl[i] = f(x)
end
return nl
end
end
square = map(function (x) return x * x end)
print(table.unpack(square{ 1, 5, 9 }))
--[[
I believe that, because the definition does not begin with function,
square is an anonymous function; it returns a value and is defined in an
expression. So, I start with the table { 1, 5, 9 }. This is the argument to
the square function. I'm guessing that the map function is called by
square. But how / why does map get the table, when map only has one
parameter, a function, and the table is not assigned to a variable? And how
/ why does map return a table value, as it seems to want to return a
function?
]]
Douglas Valenta
2018-11-07 02:58:57 UTC
Permalink
Looks like square is a function that is the return value of the call to
map. It takes a single table argument, l, and returns the table nl that
contains the squares of the values in l. Does that clear it up?

Doug
Post by Luke
Or perhaps square is not the higher order function: map is its argument
not the table?
Or is square not a function, even-though it is defined by something (map)
that returns a function, as it is not defined with 'function'?
Post by Luke
More from the documentation... thanks for any help!
function map(f)
return function (l)
local nl = {}
for i, x in ipairs(l) do
nl[i] = f(x)
end
return nl
end
end
square = map(function (x) return x * x end)
print(table.unpack(square{ 1, 5, 9 }))
--[[
I believe that, because the definition does not begin with function,
square is an anonymous function; it returns a value and is defined in an
expression. So, I start with the table { 1, 5, 9 }. This is the argument to
the square function. I'm guessing that the map function is called by
square. But how / why does map get the table, when map only has one
parameter, a function, and the table is not assigned to a variable? And how
/ why does map return a table value, as it seems to want to return a
function?
]]
Luke
2018-11-07 03:07:11 UTC
Permalink
why say that it takes the argument l rather than f or rather than x * x?
Post by Douglas Valenta
Looks like square is a function that is the return value of the call to
map. It takes a single table argument, l, and returns the table nl that
contains the squares of the values in l. Does that clear it up?
Doug
Post by Luke
Or perhaps square is not the higher order function: map is its argument
not the table?
Or is square not a function, even-though it is defined by something (map)
that returns a function, as it is not defined with 'function'?
Post by Luke
More from the documentation... thanks for any help!
function map(f)
return function (l)
local nl = {}
for i, x in ipairs(l) do
nl[i] = f(x)
end
return nl
end
end
square = map(function (x) return x * x end)
print(table.unpack(square{ 1, 5, 9 }))
--[[
I believe that, because the definition does not begin with function,
square is an anonymous function; it returns a value and is defined in an
expression. So, I start with the table { 1, 5, 9 }. This is the argument to
the square function. I'm guessing that the map function is called by
square. But how / why does map get the table, when map only has one
parameter, a function, and the table is not assigned to a variable? And how
/ why does map return a table value, as it seems to want to return a
function?
]]
Albert Chan
2018-11-07 02:59:06 UTC
Permalink
I believe that, because the definition does not begin with function, square is an anonymous function; it returns a value and is defined in an expression. So, I start with the table { 1, 5, 9 }. This is the argument to the square function. I'm guessing that the map function is called by square. But how / why does map get the table, when map only has one parameter, a function, and the table is not assigned to a variable? And how / why does map return a table value, as it seems to want to return a function?
Think of map as a function maker.
After making the function, the job of map is done.
So, map never see the list {1, 5, 9}

square stored what map function maker created.
square is now a function, that map x to x*x

square( {1,5,9} ) ==> {1,25,81}
Luke
2018-11-07 03:05:20 UTC
Permalink
Post by Albert Chan
Think of map as a function maker.
After making the function, the job of map is done.
So, map never see the list {1, 5, 9}

That makes sense. Why don't we use function to define square?

function square = map(function (x) return x * x end)
Post by Albert Chan
Post by Luke
I believe that, because the definition does not begin with function,
square is an anonymous function; it returns a value and is defined in an
expression. So, I start with the table { 1, 5, 9 }. This is the argument to
the square function. I'm guessing that the map function is called by
square. But how / why does map get the table, when map only has one
parameter, a function, and the table is not assigned to a variable? And how
/ why does map return a table value, as it seems to want to return a
function?
Think of map as a function maker.
After making the function, the job of map is done.
So, map never see the list {1, 5, 9}
square stored what map function maker created.
square is now a function, that map x to x*x
square( {1,5,9} ) ==> {1,25,81}
Erutuon
2018-11-07 03:16:27 UTC
Permalink
function square = <something or other> is not valid Lua syntax. "function"
has to be followed by (at minimum) parentheses and then "end": function ()
end. See the section in the Lua manual on function definitions (
https://www.lua.org/manual/5.3/manual.html#3.4.11).

— Gabriel
Post by Albert Chan
Post by Albert Chan
Think of map as a function maker.
After making the function, the job of map is done.
So, map never see the list {1, 5, 9}
That makes sense. Why don't we use function to define square?
function square = map(function (x) return x * x end)
Post by Albert Chan
Post by Luke
I believe that, because the definition does not begin with function,
square is an anonymous function; it returns a value and is defined in an
expression. So, I start with the table { 1, 5, 9 }. This is the argument to
the square function. I'm guessing that the map function is called by
square. But how / why does map get the table, when map only has one
parameter, a function, and the table is not assigned to a variable? And how
/ why does map return a table value, as it seems to want to return a
function?
Think of map as a function maker.
After making the function, the job of map is done.
So, map never see the list {1, 5, 9}
square stored what map function maker created.
square is now a function, that map x to x*x
square( {1,5,9} ) ==> {1,25,81}
Luke
2018-11-07 03:27:49 UTC
Permalink
yeah, thanks, I got that.

function f()
return 3 end
thing = f
print(type(thing), thing())

thing is a function, but I was confused that you needed to add the
parentheses to get print to print its value.

I guess syntax just is the way it is?
Post by Erutuon
function square = <something or other> is not valid Lua syntax. "function"
has to be followed by (at minimum) parentheses and then "end": function ()
end. See the section in the Lua manual on function definitions (
https://www.lua.org/manual/5.3/manual.html#3.4.11).
— Gabriel
Post by Albert Chan
Post by Albert Chan
Think of map as a function maker.
After making the function, the job of map is done.
So, map never see the list {1, 5, 9}
That makes sense. Why don't we use function to define square?
function square = map(function (x) return x * x end)
Post by Albert Chan
Post by Luke
I believe that, because the definition does not begin with function,
square is an anonymous function; it returns a value and is defined in an
expression. So, I start with the table { 1, 5, 9 }. This is the argument to
the square function. I'm guessing that the map function is called by
square. But how / why does map get the table, when map only has one
parameter, a function, and the table is not assigned to a variable? And how
/ why does map return a table value, as it seems to want to return a
function?
Think of map as a function maker.
After making the function, the job of map is done.
So, map never see the list {1, 5, 9}
square stored what map function maker created.
square is now a function, that map x to x*x
square( {1,5,9} ) ==> {1,25,81}
Luke
2018-11-08 00:02:16 UTC
Permalink
Is it right to say that we call a function when it appears in a
statement with parentheses after it? I'm also a little confused about
the difference between a variable and the value, e.g. if they can be
of a different type?

Sorry to go on: I just have zero experience of programming.. The
reference manual is unreadable in places, as yet. So I'm switching
between the lecture notes and book. Hopefully I won't have to keep
asking questions to the list. I had similar issues reading the manual
for ubuntu, and had to give up. I wonder if there's a webresource etc.
that includes a glossary necessary to understand manuals etc.

Cheers,
Luke
Post by Luke
yeah, thanks, I got that.
function f()
return 3 end
thing = f
print(type(thing), thing())
thing is a function, but I was confused that you needed to add the parentheses to get print to print its value.
I guess syntax just is the way it is?
function square = <something or other> is not valid Lua syntax. "function" has to be followed by (at minimum) parentheses and then "end": function () end. See the section in the Lua manual on function definitions (https://www.lua.org/manual/5.3/manual.html#3.4.11).
— Gabriel
Post by Albert Chan
Post by Albert Chan
Think of map as a function maker.
After making the function, the job of map is done.
So, map never see the list {1, 5, 9}
That makes sense. Why don't we use function to define square?
function square = map(function (x) return x * x end)
Post by Albert Chan
I believe that, because the definition does not begin with function, square is an anonymous function; it returns a value and is defined in an expression. So, I start with the table { 1, 5, 9 }. This is the argument to the square function. I'm guessing that the map function is called by square. But how / why does map get the table, when map only has one parameter, a function, and the table is not assigned to a variable? And how / why does map return a table value, as it seems to want to return a function?
Think of map as a function maker.
After making the function, the job of map is done.
So, map never see the list {1, 5, 9}
square stored what map function maker created.
square is now a function, that map x to x*x
square( {1,5,9} ) ==> {1,25,81}
Paul Merrell
2018-11-08 00:16:10 UTC
Permalink
Post by Luke
I wonder if there's a webresource etc.
that includes a glossary necessary to understand manuals etc.
<https://rawgit.com/dlaurie/lua-notes/master/glossary.html>.
Luke
2018-11-08 00:26:32 UTC
Permalink
Thanks. I wonder why no definition of 'operator'
Cheers
Post by Paul Merrell
Post by Luke
I wonder if there's a webresource etc.
that includes a glossary necessary to understand manuals etc.
<https://rawgit.com/dlaurie/lua-notes/master/glossary.html>.
Luke
2018-11-08 00:32:47 UTC
Permalink
And what brackets mean in the reference manual's list of basic functions e.g.

assert (v [, message])

Luke
Post by Luke
Thanks. I wonder why no definition of 'operator'
Cheers
Post by Paul Merrell
Post by Luke
I wonder if there's a webresource etc.
that includes a glossary necessary to understand manuals etc.
<https://rawgit.com/dlaurie/lua-notes/master/glossary.html>.
Gabriel Bertilson
2018-11-08 00:35:39 UTC
Permalink
Brackets mean that something is optional. In this case, you can call
the function with one or two arguments: `assert(v)` or `assert(v,
message)`.

— Gabriel
Post by Luke
And what brackets mean in the reference manual's list of basic functions e.g.
assert (v [, message])
Luke
Post by Luke
Thanks. I wonder why no definition of 'operator'
Cheers
Post by Paul Merrell
Post by Luke
I wonder if there's a webresource etc.
that includes a glossary necessary to understand manuals etc.
<https://rawgit.com/dlaurie/lua-notes/master/glossary.html>.
Luke
2018-11-08 00:41:13 UTC
Permalink
Thanks again. Is anything else needed available in order to understand
the reference manual? e.g. I found out that ::= means is defined as (I
assume backwards) but much of the following is beyond me

prefixexp ::= var | functioncall | ‘(’ exp ‘)’
On Thu, 8 Nov 2018 at 00:36, Gabriel Bertilson
Post by Gabriel Bertilson
Brackets mean that something is optional. In this case, you can call
the function with one or two arguments: `assert(v)` or `assert(v,
message)`.
— Gabriel
Post by Luke
And what brackets mean in the reference manual's list of basic functions e.g.
assert (v [, message])
Luke
Post by Luke
Thanks. I wonder why no definition of 'operator'
Cheers
Post by Paul Merrell
Post by Luke
I wonder if there's a webresource etc.
that includes a glossary necessary to understand manuals etc.
<https://rawgit.com/dlaurie/lua-notes/master/glossary.html>.
Jonathan Goble
2018-11-08 00:54:27 UTC
Permalink
Post by Luke
Thanks again. Is anything else needed available in order to understand
the reference manual? e.g. I found out that ::= means is defined as (I
assume backwards) but much of the following is beyond me
prefixexp ::= var | functioncall | ‘(’ exp ‘)’
That is the formal grammar, which a beginner like you need not worry about.
The grammar is intended more for experts.

In general, the reference manual is designed to be a concise definition of
the language and assumes a certain level of programming knowledge,
including some familiarity with Lua itself. It is not a good place for a
beginner to learn from.

I recommend obtaining the Programming in Lua book; it is written by the Lua
team and is much more user- and beginner-friendly, with longer discussions
of the topics and many examples. The first edition of the book is available
on lua.org, but was written for Lua 5.0. Lua has undergone several major
revisions and changes since then, so some of the material in that version
is outdated. The fourth edition of Programming in Lua covers Lua 5.3 (the
latest release of Lua) and is available on Amazon and possibly other
places. It is well worth the cost, especially if you are trying to learn.
Luke
2018-11-08 01:00:22 UTC
Permalink
I will buy the e-book. If it does not include exercises / homework
then where might I find that sort of thing?
Post by Luke
Thanks again. Is anything else needed available in order to understand
the reference manual? e.g. I found out that ::= means is defined as (I
assume backwards) but much of the following is beyond me
prefixexp ::= var | functioncall | ‘(’ exp ‘)’
That is the formal grammar, which a beginner like you need not worry about. The grammar is intended more for experts.
In general, the reference manual is designed to be a concise definition of the language and assumes a certain level of programming knowledge, including some familiarity with Lua itself. It is not a good place for a beginner to learn from.
I recommend obtaining the Programming in Lua book; it is written by the Lua team and is much more user- and beginner-friendly, with longer discussions of the topics and many examples. The first edition of the book is available on lua.org, but was written for Lua 5.0. Lua has undergone several major revisions and changes since then, so some of the material in that version is outdated. The fourth edition of Programming in Lua covers Lua 5.3 (the latest release of Lua) and is available on Amazon and possibly other places. It is well worth the cost, especially if you are trying to learn.
Jonathan Goble
2018-11-08 01:03:41 UTC
Permalink
Post by Luke
I will buy the e-book. If it does not include exercises / homework
then where might I find that sort of thing?
The latest editions (3rd and 4th, IIRC) of Programming in Lua do include
exercises at the end of each chapter.
Luke
2018-11-09 00:10:48 UTC
Permalink
Post by Luke
exercises
I'm guessing no glossary then. That's a shame, they are useful
additions to an introduction to anything. e.g. there is no definition
of 'seed' in the lua glosasry linked to, wikipedia, or my dictionary

Perhaps these questions are too genetic, however.

Luke
Post by Luke
Post by Luke
I will buy the e-book. If it does not include exercises / homework
then where might I find that sort of thing?
The latest editions (3rd and 4th, IIRC) of Programming in Lua do include exercises at the end of each chapter.
Dirk Laurie
2018-11-09 03:30:42 UTC
Permalink
Post by Luke
I'm guessing no glossary then. That's a shame, they are useful
additions to an introduction to anything. e.g. there is no definition
of 'seed' in the lua glosasry linked to, wikipedia, or my dictionary
There is an unofficial glossary, dealing mostly with background
knowledge that the reader of the offficial documentation is assumed
to, but does not always, have. "It does not cover advanced concepts."
I'm afraid that "seed", depending as it does on "pseudo-random" , has
so far fallen in that category.

https://rawgit.com/dlaurie/lua-notes/master/glossary.html
Luke
2018-11-09 09:12:29 UTC
Permalink
That's a shame.

Are these "advanced concepts" difficult to learn or do they just
depend on handful of other terms? Seed was in the lectures' definition
of fold, and then the next slide confused confused me further:

A curried function is a function that, instead of taking all of
its parameters at once, takes a proper prefix of them and then returns
a (possibly also curried) function that takes the rest of the
parameters; for example, the following is curried version of map

But I believe that map never takes any parameters other than the
function it is called with: square builds a new function from a map
function that never sees the table. I am a graduate, and am used to
slightly vague slides that need filling in by the lecturer. And I'm
not complaining! Free stuff is good just feel like something is
missing. I said the same for ubuntu!

Cheers,
Luke
Post by Dirk Laurie
Post by Luke
I'm guessing no glossary then. That's a shame, they are useful
additions to an introduction to anything. e.g. there is no definition
of 'seed' in the lua glosasry linked to, wikipedia, or my dictionary
There is an unofficial glossary, dealing mostly with background
knowledge that the reader of the offficial documentation is assumed
to, but does not always, have. "It does not cover advanced concepts."
I'm afraid that "seed", depending as it does on "pseudo-random" , has
so far fallen in that category.
https://rawgit.com/dlaurie/lua-notes/master/glossary.html
Sean Conner
2018-11-09 19:07:25 UTC
Permalink
Post by Luke
That's a shame.
Are these "advanced concepts" difficult to learn or do they just
depend on handful of other terms? Seed was in the lectures' definition
Some, like "map" or "fold", are not difficult but depend upon other concepts;
others like "monad" are so opaque as to defy definition (a monad is just a
monoid in the category of endofunctors, or so I'm told, but I'm not a
mathematician or type theorist).
Post by Luke
But I believe that map never takes any parameters other than the
function it is called with: square builds a new function from a map
function that never sees the table.
Maybe "a" particular implementation of map() will do that, but not all.
In general, you have three related concepts: map, filter, reduce (or fold).

map: maps a list of values to new values, for instance:

x = { 1 , 2 , 3 , 4}
y = map(x,function(x) return x * x end)
-- y has { 1 , 4 , 9 , 16 }

filter: filters out values that fit some criteria into a new list.

y = filter(x,function(x) return x % 2 == 0 end)
-- y has { 2 , 4 }

reduce (aka fold): maps a list of values to a single result, such
as the sum of all items:

y = reduce(x,function(a,b) return a + b end)
-- y is now 10

The think to keep in mind is that in general, map() need not work "left to
right" (it can do it right to left, or all at the same time, etc.).
reduce() will usually go "left to right" and if you need the opposite
direction, there might be a reducer() function; filter works simularly, but
as always, check the manual before using.

Also, every instance I've seen (in other langauges; other implementations)
map() will also always take the data and a function to run over the items;
same for filter() and reduce().

-spc (Remember, the meanings behind these terms will come in time,
except for monads ... )
Luke
2018-11-09 19:19:16 UTC
Permalink
t was thus said that the Great Luke once stated
What, I'm just giving on opinion on what learning lua is like...
there's really no need to be rude at all

Luke
Post by Luke
That's a shame.
Are these "advanced concepts" difficult to learn or do they just
depend on handful of other terms? Seed was in the lectures' definition
Some, like "map" or "fold", are not difficult but depend upon other concepts;
others like "monad" are so opaque as to defy definition (a monad is just a
monoid in the category of endofunctors, or so I'm told, but I'm not a
mathematician or type theorist).
Post by Luke
But I believe that map never takes any parameters other than the
function it is called with: square builds a new function from a map
function that never sees the table.
Maybe "a" particular implementation of map() will do that, but not all.
In general, you have three related concepts: map, filter, reduce (or fold).
x = { 1 , 2 , 3 , 4}
y = map(x,function(x) return x * x end)
-- y has { 1 , 4 , 9 , 16 }
filter: filters out values that fit some criteria into a new list.
y = filter(x,function(x) return x % 2 == 0 end)
-- y has { 2 , 4 }
reduce (aka fold): maps a list of values to a single result, such
y = reduce(x,function(a,b) return a + b end)
-- y is now 10
The think to keep in mind is that in general, map() need not work "left to
right" (it can do it right to left, or all at the same time, etc.).
reduce() will usually go "left to right" and if you need the opposite
direction, there might be a reducer() function; filter works simularly, but
as always, check the manual before using.
Also, every instance I've seen (in other langauges; other implementations)
map() will also always take the data and a function to run over the items;
same for filter() and reduce().
-spc (Remember, the meanings behind these terms will come in time,
except for monads ... )
Luke
2018-11-09 19:21:29 UTC
Permalink
My expertise is in not being as clever as everyone else. There's no
need to take that personally!
Post by Luke
t was thus said that the Great Luke once stated
What, I'm just giving on opinion on what learning lua is like...
there's really no need to be rude at all
Luke
Post by Luke
That's a shame.
Are these "advanced concepts" difficult to learn or do they just
depend on handful of other terms? Seed was in the lectures' definition
Some, like "map" or "fold", are not difficult but depend upon other concepts;
others like "monad" are so opaque as to defy definition (a monad is just a
monoid in the category of endofunctors, or so I'm told, but I'm not a
mathematician or type theorist).
Post by Luke
But I believe that map never takes any parameters other than the
function it is called with: square builds a new function from a map
function that never sees the table.
Maybe "a" particular implementation of map() will do that, but not all.
In general, you have three related concepts: map, filter, reduce (or fold).
x = { 1 , 2 , 3 , 4}
y = map(x,function(x) return x * x end)
-- y has { 1 , 4 , 9 , 16 }
filter: filters out values that fit some criteria into a new list.
y = filter(x,function(x) return x % 2 == 0 end)
-- y has { 2 , 4 }
reduce (aka fold): maps a list of values to a single result, such
y = reduce(x,function(a,b) return a + b end)
-- y is now 10
The think to keep in mind is that in general, map() need not work "left to
right" (it can do it right to left, or all at the same time, etc.).
reduce() will usually go "left to right" and if you need the opposite
direction, there might be a reducer() function; filter works simularly, but
as always, check the manual before using.
Also, every instance I've seen (in other langauges; other implementations)
map() will also always take the data and a function to run over the items;
same for filter() and reduce().
-spc (Remember, the meanings behind these terms will come in time,
except for monads ... )
Luke
2018-11-09 19:24:30 UTC
Permalink
Those weren't ironic quotes, and, while I appreciate the reply, I took
it personally.
Post by Luke
My expertise is in not being as clever as everyone else. There's no
need to take that personally!
Post by Luke
t was thus said that the Great Luke once stated
What, I'm just giving on opinion on what learning lua is like...
there's really no need to be rude at all
Luke
Post by Luke
That's a shame.
Are these "advanced concepts" difficult to learn or do they just
depend on handful of other terms? Seed was in the lectures' definition
Some, like "map" or "fold", are not difficult but depend upon other concepts;
others like "monad" are so opaque as to defy definition (a monad is just a
monoid in the category of endofunctors, or so I'm told, but I'm not a
mathematician or type theorist).
Post by Luke
But I believe that map never takes any parameters other than the
function it is called with: square builds a new function from a map
function that never sees the table.
Maybe "a" particular implementation of map() will do that, but not all.
In general, you have three related concepts: map, filter, reduce (or fold).
x = { 1 , 2 , 3 , 4}
y = map(x,function(x) return x * x end)
-- y has { 1 , 4 , 9 , 16 }
filter: filters out values that fit some criteria into a new list.
y = filter(x,function(x) return x % 2 == 0 end)
-- y has { 2 , 4 }
reduce (aka fold): maps a list of values to a single result, such
y = reduce(x,function(a,b) return a + b end)
-- y is now 10
The think to keep in mind is that in general, map() need not work "left to
right" (it can do it right to left, or all at the same time, etc.).
reduce() will usually go "left to right" and if you need the opposite
direction, there might be a reducer() function; filter works simularly, but
as always, check the manual before using.
Also, every instance I've seen (in other langauges; other implementations)
map() will also always take the data and a function to run over the items;
same for filter() and reduce().
-spc (Remember, the meanings behind these terms will come in time,
except for monads ... )
Luke
2018-11-09 19:31:18 UTC
Permalink
No apology. Perhaps I'm too chatty, as well as very badly organized.

Apologies then, and good luck with your programming things :) I'm out

Luke
Coda Highland
2018-11-09 19:43:44 UTC
Permalink
Post by Luke
No apology. Perhaps I'm too chatty, as well as very badly organized.
Apologies then, and good luck with your programming things :) I'm out
Luke
That was just Sean's default reply header. It's in almost all of his
emails. Not sarcastic, not deprecating, and not even consciously done.
It's just a little more interesting than "Luke wrote:".

/s/ Adam
Sean Conner
2018-11-09 21:18:23 UTC
Permalink
Post by Coda Highland
Post by Luke
No apology. Perhaps I'm too chatty, as well as very badly organized.
Apologies then, and good luck with your programming things :) I'm out
Luke
That was just Sean's default reply header. It's in almost all of his
emails. Not sarcastic, not deprecating, and not even consciously done.
It's just a little more interesting than "Luke wrote:".
I've had that reply header since 1994. I'm not sure why now (and only on
this mailing list) that I'm getting complaints. Perhaps it's how I replied?

-spc (Although when I first set it, it said "A long long time ago on a
network far far away, The Great %s wrote:")
Robert Raschke
2018-11-10 07:51:15 UTC
Permalink
Times change, and what was once interpreted as flippant, is no longer so.

There's been a few instances now where people interpreted that intro reply
line as condescending, so maybe it's time to change it?

Cheers,
Robby
Post by Sean Conner
Post by Coda Highland
Post by Luke
No apology. Perhaps I'm too chatty, as well as very badly organized.
Apologies then, and good luck with your programming things :) I'm out
Luke
That was just Sean's default reply header. It's in almost all of his
emails. Not sarcastic, not deprecating, and not even consciously done.
It's just a little more interesting than "Luke wrote:".
I've had that reply header since 1994. I'm not sure why now (and only on
this mailing list) that I'm getting complaints. Perhaps it's how I replied?
-spc (Although when I first set it, it said "A long long time ago on a
network far far away, The Great %s wrote:")
Dirk Laurie
2018-11-10 09:25:21 UTC
Permalink
Op Sa., 10 Nov. 2018 om 09:51 het Robert Raschke
Post by Robert Raschke
Times change, and what was once interpreted as flippant, is no longer so.
There's been a few instances now where people interpreted that intro reply line as condescending, so maybe it's time to change it?
The complaints come only from newcomers who have joined and posted
without first reading a day or two's worth of previous posts.

Part of what gives any list its particular flavour is precisely the
mildly eccentric habits of its regulars. The onus is on the newcomer
to become familiar with what we say and how we say it. It goes much
deeper than just a few automatic headers and .sigs.

I do not agree that old-timers on the list should change their ways
because newcomers don't understand them. I would personally regret
much more the fed-up departure of an old-timer [1] than the huffy exit
of a newbie.

[1] When last did we see a post by —, — or —?
Tim Hill
2018-11-10 19:43:41 UTC
Permalink
Post by Dirk Laurie
Op Sa., 10 Nov. 2018 om 09:51 het Robert Raschke
Post by Robert Raschke
Times change, and what was once interpreted as flippant, is no longer so.
There's been a few instances now where people interpreted that intro reply line as condescending, so maybe it's time to change it?
The complaints come only from newcomers who have joined and posted
without first reading a day or two's worth of previous posts.
Part of what gives any list its particular flavour is precisely the
mildly eccentric habits of its regulars. The onus is on the newcomer
to become familiar with what we say and how we say it. It goes much
deeper than just a few automatic headers and .sigs.
I do not agree that old-timers on the list should change their ways
because newcomers don't understand them. I would personally regret
much more the fed-up departure of an old-timer [1] than the huffy exit
of a newbie.
[1] When last did we see a post by —, — or —?
+1 .. it’s a mild and amusing way to start a quote .. no-one should be offended by it, and if they are, well, perhaps they should reflect on that for a while.

—Tim
Lorenzo Donati
2018-11-11 16:36:21 UTC
Permalink
Post by Sean Conner
Post by Coda Highland
Post by Luke
No apology. Perhaps I'm too chatty, as well as very badly organized.
Apologies then, and good luck with your programming things :) I'm out
Luke
That was just Sean's default reply header. It's in almost all of his
emails. Not sarcastic, not deprecating, and not even consciously done.
It's just a little more interesting than "Luke wrote:".
I've had that reply header since 1994. I'm not sure why now (and only on
this mailing list) that I'm getting complaints. Perhaps it's how I replied?
It might be perceived as sarcastic only by people that didn't read
enough of past mailing list messages of yours.

Once upon a time (<wink>) people followed good netiquette and lurked for
a while on a mailing list or a forum before posting anything: the
ancient lore told that not doing so was rude against the deities of the
sacred net. And daemons could be freed from their ancient prisons had
not that ritual been followed! :-D

But nowadays all has changed: people rush in the room without even
bothering to know who's who and they require everyone to give them
whatever they want, not even thanking for it <"gimmeee the codeeez!">
(BTW, I'm not saying that this is the OP's attitude).

Linguistic barrier could also be a problem, non-native speakers might
not recognize that "ancient speak" nuance of the opening. But, again, a
decent dose of lurking should convince anyone at least that that is just
boilerplate text, not meant to belittle anyone.

BTW, I was always amused by that opening: It's like a character from
Tolkien or Shakespeare is about to jump out from the darkness and take
life while reading your posts :-)
Post by Sean Conner
-spc (Although when I first set it, it said "A long long time ago on a
network far far away, The Great %s wrote:")
May the force be with you! :-D

Albert Chan
2018-11-07 03:24:19 UTC
Permalink
Post by Albert Chan
Post by Albert Chan
Think of map as a function maker.
After making the function, the job of map is done.
So, map never see the list {1, 5, 9}
That makes sense. Why don't we use function to define square?
function square = map(function (x) return x * x end)
Because the function is *already* defined from map.
All we need is store this function object into a variable, name "square"
(besides, above is not valid lua code)

You can also think like this:

function add1(x) return x+1 end

is same as:

add1 = function(x) return x+1 end
Erutuon
2018-11-07 03:10:38 UTC
Permalink
Apparently, 1e-4 (it shouldn't have any spaces) is a numerical literal
in Lua 5.3, where it is close to 1 * 10^-4, though at least in my Lua
1e-4 is not quite equal to 1 * 10^-4, because the former is roughly
0.000100000000000000004792173602 and the latter is roughly
0.000100000000000000045449755071 .

It is apparently not a valid number in Lua 5.1 though, where I get a
syntax error "unexpected symbol near 1e-4". So maybe you're using Lua
5.1, not 5.3?

1e - 4 (with spaces around the hyphen) is invalid syntax in both Lua
5.3 and 5.1: "malformed number near '1e' ".

— Gabriel
Post by Luke
Hi,
I'm not getting some of the examples in the slides
t = table.pack(1, nil, 3)
for i = 1, t.n do
print(t[i])
end
Does t.n give the value of' 3?
for k, v in pairs(tab) do
What does in do in this line of code?
function derivative(f, dx)
dx = dx or 1e - 4
return
function (x)
return(f(x + dx) - f(x)) / dx
end
end
I get an error message running this, from the lecture'"more on function".
Do resources like this mean I might one day use CSound in lua
interpreted by C++ without knowing C?
github.com/csound/csoundAPI_examples/tree/master/lua
Cheers,
Luke
Luke
2018-11-07 03:12:54 UTC
Permalink
Thanks to everyone. Sorry for being slow and for the mistakes I've made.

Best,
Luke
Post by Erutuon
Apparently, 1e-4 (it shouldn't have any spaces) is a numerical literal
in Lua 5.3, where it is close to 1 * 10^-4, though at least in my Lua
1e-4 is not quite equal to 1 * 10^-4, because the former is roughly
0.000100000000000000004792173602 and the latter is roughly
0.000100000000000000045449755071 .
It is apparently not a valid number in Lua 5.1 though, where I get a
syntax error "unexpected symbol near 1e-4". So maybe you're using Lua
5.1, not 5.3?
1e - 4 (with spaces around the hyphen) is invalid syntax in both Lua
5.3 and 5.1: "malformed number near '1e' ".
— Gabriel
Post by Luke
Hi,
I'm not getting some of the examples in the slides
t = table.pack(1, nil, 3)
for i = 1, t.n do
print(t[i])
end
Does t.n give the value of' 3?
for k, v in pairs(tab) do
What does in do in this line of code?
function derivative(f, dx)
dx = dx or 1e - 4
return
function (x)
return(f(x + dx) - f(x)) / dx
end
end
I get an error message running this, from the lecture'"more on function".
Do resources like this mean I might one day use CSound in lua
interpreted by C++ without knowing C?
github.com/csound/csoundAPI_examples/tree/master/lua
Cheers,
Luke
Roberto Ierusalimschy
2018-11-08 11:39:15 UTC
Permalink
Post by Erutuon
It is apparently not a valid number in Lua 5.1 though, where I get a
syntax error "unexpected symbol near 1e-4". So maybe you're using Lua
5.1, not 5.3?
1e-4 is a valid Lua number since day one (version 1.0). Maybe you forgot
the '=' to print it? (Until version 5.2, Lua did not directly read/print
expressions in interactive mode. You have to prefix them with a '='.)

-- Roberto
Gabriel Bertilson
2018-11-08 19:11:08 UTC
Permalink
Oops, you're right, I did forget to add an equals sign. 😔 Sorry for
spreading misinformation.

— Gabriel



On Thu, Nov 8, 2018 at 5:39 AM Roberto Ierusalimschy
Post by Roberto Ierusalimschy
Post by Erutuon
It is apparently not a valid number in Lua 5.1 though, where I get a
syntax error "unexpected symbol near 1e-4". So maybe you're using Lua
5.1, not 5.3?
1e-4 is a valid Lua number since day one (version 1.0). Maybe you forgot
the '=' to print it? (Until version 5.2, Lua did not directly read/print
expressions in interactive mode. You have to prefix them with a '='.)
-- Roberto
Luke
2018-11-08 23:47:29 UTC
Permalink
Working through the lecture notes again, for now, I can buy the e-book
shortly.
Post by Albert Chan
Think of map as a function maker.
After making the function, the job of map is done.

Is the function passed to map by square a callback? Or not, perhaps because
it is not a parameter of map, or perhaps map does not call the function?

function map(f)
return function (l)
local nl = {}
for i, x in ipairs(l) do
nl[i] = f(x)
end
return nl
end
end
square = map(function (x) return x * x end)
print(table.unpack(square{ 1, 5, 9 }))
Loading...