<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="122313" data-post-id="122313">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="NobbZ" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/NobbZ/120/27235_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  NobbZ
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="yordisprieto" data-post="3" data-topic="21267">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/yordisprieto/48/20915_2.png" class="avatar"> yordisprieto:</div>
<blockquote>
<p>hmmm when I called <code>get_templates</code> I get a partially applied function, no?</p>
</blockquote>
</aside>
<p>Exactly, Partial application is a call side thing, which is pretty easy when you have curried functions, but also possible on non curried functions, by wrapping them into a clojure.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def add(a, b), do: a + b

def add2(), do: &amp;add(2, &amp;1)
</code></pre>
<pre data-code-wrap="elixir"><code class="lang-elixir">def add(a), do: &amp;(a + &amp;1)

def add2(), do: add(2)
</code></pre>
<p>In both cases in <code>add2/0</code> we use partial application to return a function, which would add <code>2</code> to its argument.</p>
<aside class="quote no-group" data-username="yordisprieto" data-post="3" data-topic="21267">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/yordisprieto/48/20915_2.png" class="avatar"> yordisprieto:</div>
<blockquote>
<p>Where can I read more about this?</p>
</blockquote>
</aside>
<p>Just google explanations about how the scheduler assigns calculation times.</p>
<p>SImplified, each function you call will increase the reduction count of your process, and if it reaches a certain count, the process will be halted and the BEAM switches to the next one. Then other processes can run until your original is back on the table and can be run.</p>
<p>So, the more “needless” functions you call, the less CPU time you get.</p>
<aside class="quote no-group" data-username="yordisprieto" data-post="3" data-topic="21267">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/yordisprieto/48/20915_2.png" class="avatar"> yordisprieto:</div>
<blockquote>
<p>separate the API from the dependency injection portion of it.</p>
</blockquote>
</aside>
<p>I rarely use DI. And if I do, I usually consider it a part of the API. I do treat is quite often as call-site configuration ovverrides and handle them as part of the passed in config map/KW-list.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="122313" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/partial-application-vs-parameters-which-do-you-prefer/21267/4">Post #3</a>
	                </div>
	            </div>
              <div id="likers-container-122313" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="122313"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #3"></div>
  </section>
</div>
    <div class="postbit" id="122312" data-post-id="122312">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="yordisprieto" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/yordisprieto/120/20915_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  yordisprieto
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="NobbZ" data-post="2" data-topic="21267">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/48/27235_2.png" class="avatar"> NobbZ:</div>
<blockquote>
<p>Also your curried example is not valid elixir, as anonymous functions can’t have optional parameters</p>
</blockquote>
</aside>
<p>Yeah, my bad, I just copied pasted the code <img src="https://forum.elixirforum.com/images/emoji/apple/sweat_smile.png?v=15" title=":sweat_smile:" class="emoji" alt=":sweat_smile:" loading="lazy" width="20" height="20"></p>
<aside class="quote no-group" data-username="NobbZ" data-post="2" data-topic="21267">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/48/27235_2.png" class="avatar"> NobbZ:</div>
<blockquote>
<p>Also in elixir and erlang curried functions are expensive in terms of reduction count, as they are recursive calls that might not be necessary.</p>
</blockquote>
</aside>
<p>Where can I read more about this? I don’t understand what you mean. Does this mean that I shouldn’t go crazy with FP in Elixir?</p>
<aside class="quote no-group" data-username="NobbZ" data-post="2" data-topic="21267">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/48/27235_2.png" class="avatar"> NobbZ:</div>
<blockquote>
<p>(your second example is not partial application)</p>
</blockquote>
</aside>
<p>hmmm when I called <code>get_templates</code> I get a partially applied function, no? I guess I miss understood about this</p>
<p>I just googled this since I keep getting confused what people mean about Curry vs Partial Application <a href="https://stackoverflow.com/questions/218025/what-is-the-difference-between-currying-and-partial-application" rel="noopener nofollow ugc">https://stackoverflow.com/questions/218025/what-is-the-difference-between-currying-and-partial-application</a></p>
<p>But this is going sideways.</p>
<aside class="quote no-group" data-username="NobbZ" data-post="2" data-topic="21267">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/48/27235_2.png" class="avatar"> NobbZ:</div>
<blockquote>
<p>But now I rarely feel the need.</p>
</blockquote>
</aside>
<p>Yeah, I just miss the clearness of such of style since it is easier to separate the API from the dependency injection portion of it.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="122312" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/partial-application-vs-parameters-which-do-you-prefer/21267/3">Post #2</a>
	                </div>
	            </div>
              <div id="likers-container-122312" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="122312"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #2"></div>
  </section>
</div>
    <div class="postbit" id="122310" data-post-id="122310">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="NobbZ" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/NobbZ/120/27235_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  NobbZ
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Without library support I think writing curried functions (your second example is not partial application) is tedious. Also in elixir and erlang curried functions are expensive in terms of reduction count, as they are recursive calls that might not be necessary.</p>
<p>Especially when they are arpitrarily nested.</p>
<p>Also your curried example is not valid elixir, as anonymous functions can’t have optional parameters.</p>
<p>But yes, in general, I like partial application and currying, but in elixir/erlang I only felt to do so during the start, when I came from Haskell and was used to use that style. But now I rarely feel the need.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="122310" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/partial-application-vs-parameters-which-do-you-prefer/21267/2">Post #1</a>
	                </div>
	            </div>
              <div id="likers-container-122310" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="122310"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-first-post cat-first-post" title="First post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>