changeset 565:22bfd8a2eaee

do Table documentation; replace Table.clone and Table.sub_list with Table.copy;
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 05 Jul 2015 00:47:00 -0600
parents c8d4d69c6dd4
children 90b93790c544
files core/src/luan/modules/Table.luan core/src/luan/modules/TableLuan.java lucene/src/luan/modules/lucene/Versioning.luan website/src/manual.html.luan website/src/site.css
diffstat 5 files changed, 52 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
diff -r c8d4d69c6dd4 -r 22bfd8a2eaee core/src/luan/modules/Table.luan
--- a/core/src/luan/modules/Table.luan	Sat Jul 04 20:57:24 2015 -0600
+++ b/core/src/luan/modules/Table.luan	Sun Jul 05 00:47:00 2015 -0600
@@ -3,14 +3,13 @@
 
 local M = {}
 
-M.clone = TableLuan.clone
 M.concat = TableLuan.concat
+M.copy = TableLuan.copy
 M.insert = TableLuan.insert
 M.new_property_table = TableLuan.new_property_table
 M.pack = TableLuan.pack
 M.remove = TableLuan.remove
 M.sort = TableLuan.sort
-M.sub_list = TableLuan.sub_list
 M.unpack = TableLuan.unpack
 
 
diff -r c8d4d69c6dd4 -r 22bfd8a2eaee core/src/luan/modules/TableLuan.java
--- a/core/src/luan/modules/TableLuan.java	Sat Jul 04 20:57:24 2015 -0600
+++ b/core/src/luan/modules/TableLuan.java	Sun Jul 05 00:47:00 2015 -0600
@@ -100,16 +100,14 @@
 		return list.toArray();
 	}
 
-	public static LuanTable sub_list(LuanState luan,LuanTable list,int from,int to) throws LuanException {
-		if( list.getMetatable() != null )
-			throw luan.exception("can't sub_list a table with a metatable");
+	public static LuanTable copy(LuanTable list,Integer from,Integer to) {
+		if( from == null )
+			return new LuanTable(list);
+		if( to == null )
+			to = list.rawLength();
 		return list.rawSubList(from,to);
 	}
 
-	public static LuanTable clone(LuanTable tbl) {
-		return new LuanTable(tbl);
-	}
-
 	public static LuanTable new_property_table() {
 		return LuanPropertyMeta.INSTANCE.newTable();
 	}
diff -r c8d4d69c6dd4 -r 22bfd8a2eaee lucene/src/luan/modules/lucene/Versioning.luan
--- a/lucene/src/luan/modules/lucene/Versioning.luan	Sat Jul 04 20:57:24 2015 -0600
+++ b/lucene/src/luan/modules/lucene/Versioning.luan	Sun Jul 05 00:47:00 2015 -0600
@@ -9,7 +9,7 @@
 local sub = String.sub or error()
 local string_to_number = String.to_number or error()
 local Table = require "luan:Table"
-local clone = Table.clone or error()
+local copy = Table.copy or error()
 local Lucene = require "luan:lucene/Lucene"
 require "luan:logging/init"
 local Logging = require "luan:logging/Logging"
@@ -38,7 +38,7 @@
 	db.indexed_fields["id index"] = Lucene.type.string
 	db.advanced_search( Lucene.literal"id index" .. ":*", function(_,doc_fn)
 		local doc = doc_fn()
-		for field, value in pairs(clone(doc)) do
+		for field, value in pairs(copy(doc)) do
 			if matches(field,".* index") then
 				local new_field = sub(field,1,-7)
 				db.indexed_fields[new_field] or error("field '"..new_field.."' not indexed")
diff -r c8d4d69c6dd4 -r 22bfd8a2eaee website/src/manual.html.luan
--- a/website/src/manual.html.luan	Sat Jul 04 20:57:24 2015 -0600
+++ b/website/src/manual.html.luan	Sun Jul 05 00:47:00 2015 -0600
@@ -91,6 +91,7 @@
 		<li><a href="#luan_lib">Basic Functions</a></li>
 		<li><a href="#package_lib">Modules</a></li>
 		<li><a href="#string_lib">String Manipulation</a></li>
+		<li><a href="#table_lib">Table Manipulation</a></li>
 	</ul>
 </div>
 
@@ -2657,27 +2658,25 @@
 
 
 
-<h2>6.6 &ndash; <a name="6.6">Table Manipulation</a></h2>
+<h3 heading><a name="table_lib">Table Manipulation</a></h3>
+
+<p>
+Include this library by:
+
+<pre>
+	local Table = require "luan:Table"
+</pre>
 
 <p>
 This library provides generic functions for table manipulation.
-It provides all its functions inside the table <a name="pdf-table"><code>table</code></a>.
-
-
-<p>
-Remember that, whenever an operation needs the length of a table,
-the table must be a proper sequence
-or have a <code>__len</code> metamethod (see <a href="#3.4.7">&sect;3.4.7</a>).
-All functions ignore non-numeric keys
-in the tables given as arguments.
-
-
-<p>
-<hr><h3><a name="pdf-table.concat"><code>table.concat (list [, sep [, i [, j]]])</code></a></h3>
-
-
-<p>
-Given a list where all elements are strings or numbers,
+It provides all its functions inside the table <code>Table</code>.
+
+
+
+<h4 heading><a name="Table.concat"><code>Table.concat (list [, sep [, i [, j]]])</code></a></h4>
+
+<p>
+Given a list,
 returns the string <code>list[i]..sep..list[i+1] &middot;&middot;&middot; sep..list[j]</code>.
 The default value for <code>sep</code> is the empty string,
 the default for <code>i</code> is 1,
@@ -2685,42 +2684,25 @@
 If <code>i</code> is greater than <code>j</code>, returns the empty string.
 
 
-
-
-<p>
-<hr><h3><a name="pdf-table.insert"><code>table.insert (list, [pos,] value)</code></a></h3>
-
+<h4 heading><a name="Table.copy"><code>Table.copy (tbl [, i [, j]])</code></a></h4>
+
+<p>
+If <code>i</code> is <code>nil</code>, returns a shallow copy of <code>tbl</code>.
+Otherwise returns a new table which is a list of the elements <code>tbl[i] &middot;&middot;&middot; tbl[j]</code>.
+By default, <code>j</code> is <code>#tbl</code>.
+
+
+
+<h4 heading><a name="Table.insert"><code>Table.insert (list, pos, value)</code></a></h4>
 
 <p>
 Inserts element <code>value</code> at position <code>pos</code> in <code>list</code>,
 shifting up the elements
 <code>list[pos], list[pos+1], &middot;&middot;&middot;, list[#list]</code>.
-The default value for <code>pos</code> is <code>#list+1</code>,
-so that a call <code>table.insert(t,x)</code> inserts <code>x</code> at the end
-of list <code>t</code>.
-
-
-
-
-<p>
-<hr><h3><a name="pdf-table.move"><code>table.move (a1, f, e, t [,a2])</code></a></h3>
-
-
-<p>
-Moves elements from table <code>a1</code> to table <code>a2</code>.
-This function performs the equivalent to the following
-multiple assignment:
-<code>a2[t],&middot;&middot;&middot; = a1[f],&middot;&middot;&middot;,a1[e]</code>.
-The default for <code>a2</code> is <code>a1</code>.
-The destination range can overlap with the source range.
-Index <code>f</code> must be positive.
-
-
-
-
-<p>
-<hr><h3><a name="pdf-table.pack"><code>table.pack (&middot;&middot;&middot;)</code></a></h3>
-
+
+
+
+<h4 heading><a name="Table.pack"><code>Table.pack (&middot;&middot;&middot;)</code></a></h4>
 
 <p>
 Returns a new table with all parameters stored into keys 1, 2, etc.
@@ -2730,8 +2712,7 @@
 
 
 
-<p>
-<hr><h3><a name="pdf-table.remove"><code>table.remove (list [, pos])</code></a></h3>
+<h4 heading><a name="Table.remove"><code>Table.remove (list, pos)</code></a></h4>
 
 
 <p>
@@ -2746,17 +2727,9 @@
 in those cases, the function erases the element <code>list[pos]</code>.
 
 
-<p>
-The default value for <code>pos</code> is <code>#list</code>,
-so that a call <code>table.remove(l)</code> removes the last element
-of list <code>l</code>.
-
-
-
-
-<p>
-<hr><h3><a name="pdf-table.sort"><code>table.sort (list [, comp])</code></a></h3>
-
+
+
+<h4 heading><a name="Table.sort"><code>Table.sort (list [, comp])</code></a></h4>
 
 <p>
 Sorts list elements in a given order, <em>in-place</em>,
@@ -2769,7 +2742,6 @@
 If <code>comp</code> is not given,
 then the standard Lua operator <code>&lt;</code> is used instead.
 
-
 <p>
 The sort algorithm is not stable;
 that is, elements considered equal by the given order
@@ -2777,10 +2749,7 @@
 
 
 
-
-<p>
-<hr><h3><a name="pdf-table.unpack"><code>table.unpack (list [, i [, j]])</code></a></h3>
-
+<h4 heading><a name="Table.unpack"><code>Table.unpack (list [, i [, j]])</code></a></h4>
 
 <p>
 Returns the elements from the given list.
@@ -2788,7 +2757,9 @@
 
 <pre>
      return list[i], list[i+1], &middot;&middot;&middot;, list[j]
-</pre><p>
+</pre>
+
+<p>
 By default, <code>i</code> is&nbsp;1 and <code>j</code> is <code>#list</code>.
 
 
diff -r c8d4d69c6dd4 -r 22bfd8a2eaee website/src/site.css
--- a/website/src/site.css	Sat Jul 04 20:57:24 2015 -0600
+++ b/website/src/site.css	Sun Jul 05 00:47:00 2015 -0600
@@ -30,3 +30,8 @@
 	margin: 2em 0 0.6em;
 	color: #233E93;
 }
+
+h4 code {
+	font-size: 1.4em;
+	font-weight: normal;
+}