Skip to content

Instantly share code, notes, and snippets.

Schönfinkelisation and Partial Application

As we discussed in a previous article, one of the things we can do with a function is to call it with fewer arguments than it is expecting. This will result in a new function where the arguments we did provide are bound to values, and the reminding arguments are still expected as parameters. Since we apply the function to only some of its arguments, we call this technique partial application.

Let's see how this works in Elm:

-- A simple function, adding together two arguments.
-- If you find the type signature confusing, don't worry
-- about that for now.

What is Functional Programming?

Hi there, and welcome to this advent calendar! While you wait for Christmas, we'll provide you with an article related to Functional Programming (FP) each day until December 24 🎅

We will try to tackle a wide range of topics. We will cover a few "classic" FP-concepts, both basic and more advanced. We also aim to have some articles with a more practical focus. Some posts will be intended for beginners and some will have a more experienced audience in mind. So if a particular article isn't for you, hopefully the next one will be!

To get the show on the road, lets start out by answering the following question:

So, what is FP anyway?

@kvalle
kvalle / elm.md
Last active March 8, 2018 17:28
FP-ressurser
@kvalle
kvalle / notes.md
Last active September 25, 2015 05:12
Future Programming Workshop - SL2015

Programmeringens fremtid

Som programmerere, hvordan kommer hverdagen vår til å se ut i fremtiden? Det er spørsmålet vi forsøker å besvare på Future Programming Workshop, en event som arrangeres dagen før StrangeLoop 2015.

Som arrangøren formulerte det innledningsvis, "at StrangeLoop you'll see a lot of stuff that actually works, but what about five or ten years from now?" Vi forsøker vi å løfte blikket for å få et glimt av hva som rører seg på horisonten.

De store linjene

Hvis vi myser litt, så kan dagens temaer grovt deles inn i to kategorier:

@kvalle
kvalle / extreme-flask.py
Created October 10, 2013 15:20
Enkel server for Extreme Startup med Flask i Python
import re
from flask import Flask, request
app = Flask(__name__)
@app.route('/', endpoint='index')
def index():
question = request.args.get("q", "").partition(": ")[2]
answer = "the answer"
print "\nQ: %s?\nA: %s" % (question, answer)
@kvalle
kvalle / fizzbuzz.py
Last active June 20, 2016 14:31
Fizzbuzz, using Python generator expression and iterators
from itertools import cycle, islice, izip, imap
fizz = cycle([""]*2 + ["fizz"])
buzz = cycle([""]*4 + ["buzz"])
fizzbuzz = imap(lambda (i, x): x[0]+x[1] or (i+1), enumerate(izip(fizz,buzz)))
print list(islice(fizzbuzz, 100))
@kvalle
kvalle / hw7testsprovided.sml
Last active December 14, 2015 19:29
Provided tests for SML part of HW7 in Coursera course on programming languages, re-written to work with https://github.com/kvalle/sml-testing
(* University of Washington, Programming Languages, Homework 7
Based on hw7testsprovided.sml *)
use "hw7.sml";
use "testing.sml"; (* Requires https://github.com/kvalle/sml-testing to run! *)
open SmlTests;
fun real_equal(x,y) = Real.compare(x,y) = General.EQUAL;
import re
from flask import Flask, request
app = Flask(__name__)
@app.route('/', endpoint='index')
def index():
question = request.args.get("q", "").partition(": ")[2]
answer = solve(question)
print "\nQ: %s?\nA: %s" % (question, answer)
@kvalle
kvalle / asserts.sml
Last active December 12, 2015 05:58
Tests for coursera-pl hw3
fun assert_equals (expected, actual, formatter) =
if expected = actual
then " -- PASS"
else "Expected: '" ^ formatter (expected) ^ "' but got '" ^ formatter (actual) ^ "' -- FAIL"
fun assert_bool_equals(expected, actual) =
if expected = actual then " -- PASS"
else "Expected: " ^ Bool.toString (expected) ^ ", but was: " ^ Bool.toString (actual) ^ " -- FAIL"
fun assert_true (actual) = assert_bool_equals(true, actual)