Tuesday, April 07, 2020

SICP in Clojure: Chapter 1, Exercise 34

This is my Clojure solution to Chapter 1, Exercise 34:

(ns sicp.ch1.ex34
  (:require [sicp.ch1.ex16 :as ch1-ex16]))

(defn f
  [g]
  (g 2))

(f ch1-ex16/square) ; => 4

(f #(* % (inc %))) ; => 6

(f f) ; => -> (f 2) -> (2 2) -- error