<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Higher-order function on OOFP 2025-26</title>
    <link>https://unibz-oofp-25-26.github.io/docs/higher/</link>
    <description>Recent content in Higher-order function on OOFP 2025-26</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <atom:link href="https://unibz-oofp-25-26.github.io/docs/higher/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Anonymous function</title>
      <link>https://unibz-oofp-25-26.github.io/docs/higher/sections/anonymous/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://unibz-oofp-25-26.github.io/docs/higher/sections/anonymous/</guid>
      <description>&lt;h1 id=&#34;anonymous-function&#34;&gt;&#xA;  Anonymous function&#xA;  &lt;a class=&#34;anchor&#34; href=&#34;#anonymous-function&#34;&gt;#&lt;/a&gt;&#xA;&lt;/h1&gt;&#xA;&lt;p&gt;We have seen in the &lt;a href=&#34;https://unibz-oofp-25-26.github.io/docs/background/sections/function/#anonymous&#34;&gt;dedicated section&lt;/a&gt; that a function can be written anonymously, as a lambda expression.&lt;/p&gt;&#xA;&lt;p&gt;Anonymous functions are a traditional feature of functional languages (like Haskell).&#xA;But they have also been integrated to a variety of imperative languages, for instance:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Python (since 1994),&lt;/li&gt;&#xA;&lt;li&gt;Javascript (since its initial release in 1995),&lt;/li&gt;&#xA;&lt;li&gt;C# (since 2007)&lt;/li&gt;&#xA;&lt;li&gt;C++ (since 2011)&lt;/li&gt;&#xA;&lt;li&gt;Java (since 2014)&lt;/li&gt;&#xA;&lt;li&gt;Rust (since its initial release in 2015)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;haskell&#34;&gt;&#xA;  In Haskell&#xA;  &lt;a class=&#34;anchor&#34; href=&#34;#haskell&#34;&gt;#&lt;/a&gt;&#xA;&lt;/h2&gt;&#xA;&lt;blockquote class=&#34;book-hint warning&#34;&gt;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Syntax.&lt;/em&gt;&lt;/strong&gt;&#xA;&amp;ldquo;$\lambda x.$&amp;rdquo; in Haskell is written &lt;code&gt;\x -&amp;gt;&lt;/code&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Currying</title>
      <link>https://unibz-oofp-25-26.github.io/docs/higher/sections/currying/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://unibz-oofp-25-26.github.io/docs/higher/sections/currying/</guid>
      <description>&lt;h1 id=&#34;currying&#34;&gt;&#xA;  Currying&#xA;  &lt;a class=&#34;anchor&#34; href=&#34;#currying&#34;&gt;#&lt;/a&gt;&#xA;&lt;/h1&gt;&#xA;&lt;p&gt;Functional programs traditionally define functions in &lt;em&gt;curried form&lt;/em&gt; (for a definition, we refer to the &lt;a href=&#34;https://unibz-oofp-25-26.github.io/docs/background/sections/function/#currying&#34;&gt;dedicated section&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;h2 id=&#34;haskell&#34;&gt;&#xA;  In Haskell&#xA;  &lt;a class=&#34;anchor&#34; href=&#34;#haskell&#34;&gt;#&lt;/a&gt;&#xA;&lt;/h2&gt;&#xA;&lt;h3 id=&#34;syntax&#34;&gt;&#xA;  Syntax&#xA;  &lt;a class=&#34;anchor&#34; href=&#34;#syntax&#34;&gt;#&lt;/a&gt;&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;A Haskell function can (in theory) take a &lt;a href=&#34;https://unibz-oofp-25-26.github.io/docs/haskell/sections/tuple/&#34;&gt;tuple&lt;/a&gt; as argument.&lt;/p&gt;&#xA;&lt;blockquote class=&#34;book-hint info&#34;&gt;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Example.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-haskell&#34; data-lang=&#34;haskell&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;power&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;::&lt;/span&gt; (&lt;span style=&#34;color:#66d9ef&#34;&gt;Int&lt;/span&gt;, &lt;span style=&#34;color:#66d9ef&#34;&gt;Int&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;Int&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;power&lt;/span&gt; (x,y) &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; x&lt;span style=&#34;color:#f92672&#34;&gt;^&lt;/span&gt;y&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/blockquote&gt;&#xA;&lt;p&gt;However, functions in &lt;a href=&#34;https://unibz-oofp-25-26.github.io/docs/background/sections/function/#currying&#34;&gt;curried form&lt;/a&gt; are usually preferred, because they are more versatile.&lt;/p&gt;&#xA;&lt;blockquote class=&#34;book-hint info&#34;&gt;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;em&gt;Example.&lt;/em&gt;&lt;/em&gt;&lt;/strong&gt; The function above in curried form can be written:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-haskell&#34; data-lang=&#34;haskell&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;power&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;::&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;Int&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;-&amp;gt;&lt;/span&gt; (&lt;span style=&#34;color:#66d9ef&#34;&gt;Int&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;Int&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;power&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;\&lt;/span&gt;x &lt;span style=&#34;color:#f92672&#34;&gt;-&amp;gt;&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;\&lt;/span&gt;y &lt;span style=&#34;color:#f92672&#34;&gt;-&amp;gt;&lt;/span&gt; x&lt;span style=&#34;color:#f92672&#34;&gt;^&lt;/span&gt;y)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or equivalently:&lt;/p&gt;</description>
    </item>
    <item>
      <title>A few higher-order functions</title>
      <link>https://unibz-oofp-25-26.github.io/docs/higher/sections/useful_hofs/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://unibz-oofp-25-26.github.io/docs/higher/sections/useful_hofs/</guid>
      <description>&lt;h1 id=&#34;a-few-higher-order-functions&#34;&gt;&#xA;  A few higher-order functions&#xA;  &lt;a class=&#34;anchor&#34; href=&#34;#a-few-higher-order-functions&#34;&gt;#&lt;/a&gt;&#xA;&lt;/h1&gt;&#xA;&lt;p&gt;We introduce a few convenient higher-order functions.&lt;/p&gt;&#xA;&lt;h2 id=&#34;haskell&#34;&gt;&#xA;  In Haskell&#xA;  &lt;a class=&#34;anchor&#34; href=&#34;#haskell&#34;&gt;#&lt;/a&gt;&#xA;&lt;/h2&gt;&#xA;&lt;!-- ### `uncurry` --&gt;&#xA;&lt;!----&gt;&#xA;&lt;!-- &lt;blockquote class=&#34;book-hint warning&#34;&gt;&#xA;   --&gt;&#xA;&lt;!-- The function --&gt;&#xA;&lt;!----&gt;&#xA;&lt;!-- ```haskell --&gt;&#xA;&lt;!-- uncurry :: (a -&gt; b -&gt; c) -&gt; (a, b) -&gt; c --&gt;&#xA;&lt;!-- ``` --&gt;&#xA;&lt;!----&gt;&#xA;&lt;!-- maps a curried function (with type `a -&gt; b -&gt; c`) into its uncurried form (with type `(a, b) -&gt; c`). --&gt;&#xA;&lt;!-- &#xA;&lt;/blockquote&gt;&#xA; --&gt;&#xA;&lt;!----&gt;&#xA;&lt;!-- &lt;blockquote class=&#34;book-hint info&#34;&gt;&#xA;   --&gt;&#xA;&lt;!-- **_Example._** --&gt;&#xA;&lt;!-- Consider the native function --&gt;&#xA;&lt;!----&gt;&#xA;&lt;!-- ```haskell --&gt;&#xA;&lt;!-- min :: Ord a =&gt; a -&gt; a -&gt; a --&gt;&#xA;&lt;!-- ``` --&gt;&#xA;&lt;!----&gt;&#xA;&lt;!-- where --&gt;&#xA;&lt;!----&gt;&#xA;&lt;!-- ```haskell --&gt;&#xA;&lt;!-- min x y --&gt;&#xA;&lt;!-- ``` --&gt;&#xA;&lt;!----&gt;&#xA;&lt;!-- is the smaller out of `x` and `y`.&lt;br&gt; --&gt;&#xA;&lt;!-- Then --&gt;&#xA;&lt;!----&gt;&#xA;&lt;!-- ```haskell --&gt;&#xA;&lt;!-- uncurry min (x,y) --&gt;&#xA;&lt;!-- ``` --&gt;&#xA;&lt;!----&gt;&#xA;&lt;!-- is the smaller out of `x` and `y`. --&gt;&#xA;&lt;!----&gt;&#xA;&lt;!-- &#xA;&lt;/blockquote&gt;&#xA; --&gt;&#xA;&lt;h3 id=&#34;filter&#34;&gt;&#xA;  &lt;code&gt;filter&lt;/code&gt;&#xA;  &lt;a class=&#34;anchor&#34; href=&#34;#filter&#34;&gt;#&lt;/a&gt;&#xA;&lt;/h3&gt;&#xA;&lt;blockquote class=&#34;book-hint warning&#34;&gt;&#xA;&lt;p&gt;The function &lt;code&gt;filter&lt;/code&gt; retains elements of a list that satisfy a certain condition.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
