<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AFun%2Fdoc</id>
	<title>Module:Fun/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AFun%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:Fun/doc&amp;action=history"/>
	<updated>2026-04-03T19:34:32Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:Fun/doc&amp;diff=214876&amp;oldid=prev</id>
		<title>Chrysophylax: Created page with &quot;&lt;code&gt;fun&lt;/code&gt; stands for &quot;functional&quot;, but also functional programming can be fun. This library contains some typical metafunctions for functional programming, such as {{co...&quot;</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:Fun/doc&amp;diff=214876&amp;oldid=prev"/>
		<updated>2021-01-02T04:34:58Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;code&amp;gt;fun&amp;lt;/code&amp;gt; stands for &amp;quot;functional&amp;quot;, but also functional programming can be fun. This library contains some typical metafunctions for functional programming, such as {{co...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;code&amp;gt;fun&amp;lt;/code&amp;gt; stands for &amp;quot;functional&amp;quot;, but also functional programming can be fun. This library contains some typical metafunctions for functional programming, such as {{code|lua|map}}, {{code|lua|some}}, {{code|lua|all}}, {{code|lua|curry}}, as well as others.&lt;br /&gt;
&lt;br /&gt;
Functions that take an array as their second argument are available as methods in the arrays created by [[Module:array]], with the arguments reversed so that they can be called as methods.&lt;br /&gt;
&lt;br /&gt;
It was started in a user sandbox ([[Module:User:Erutuon/functional]]). It is not to be confused with [https://luafun.github.io Lua Fun] (of which there is a version at [[Module:User:Erutuon/luafun]]), even though some functions are similar.&lt;br /&gt;
&lt;br /&gt;
The functions that take a table as their second argument will treat the table as an array if {{code|lua|t[1]}} is not {{code|lua|nil}}, and use {{code|lua|ipairs}}. Otherwise, they will treat it as a hashmap, using {{code|lua|pairs}}.&lt;br /&gt;
&lt;br /&gt;
; {{code|lua|function map(func, iterable)}}&lt;br /&gt;
: Perform a function {{code|lua|func}} on every element in {{code|lua|iterable}} and return the resulting table. {{code|lua|iterable}} may be a table or a string. If a table, the function operates on every element in the array portion of the table; if a string, the function operates on every UTF-8 character in the string. The function {{code|lua|func}} has the following signature: {{code|lua|func(member, i, iterable)}}. That is, the table element or UTF-8 character is first, then the index of this element, and then the iterable value (table or string).&lt;br /&gt;
; {{code|lua|function mapIter(func, iterator, iterable, initial_value)}}&lt;br /&gt;
: Create a new array from the results of performing a function on the values returned by an iterator. Can be used in combination with {{code|lua|sortedPairs}} in [[Module:table]]. {{code|lua|func}} has the same signature described above. Not very useful with {{code|lua|gmatch}}; {{code|lua|func}} would have a {{code|lua|nil}} first argument, because the single value returned from the iterator would be supplied as the second argument to {{code|lua|func}}.&lt;br /&gt;
: &amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
mapIter(&lt;br /&gt;
    function(parameter_value, parameter_name)&lt;br /&gt;
        return { parameter_name, parameter_value }&lt;br /&gt;
    end,&lt;br /&gt;
    sortedPairs(frame.args))&lt;br /&gt;
--&amp;gt; returns a sorted array of arrays containing parameter names and values&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;&lt;br /&gt;
[[Category:Lua metamodules]]&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chrysophylax</name></author>
	</entry>
</feed>