Tag Archives: Functional Programming

Function composition in Swift

The way that functional programming languages allow functions to be combined can help make code easier to read and understand. The technique is known as function composition. I show how to compose functions in Swift 3 using custom operators, including a … Continue reading

Posted in Uncategorized | Tagged , | 1 Comment

Analyzing a dependency graph in Swift

I published my solution to Dave Thomas’s Transitive Dependencies programming exercise, known as a kata, to GitHub: https://github.com/ijoshsmith/transitive-dependencies-kata The Challenge This exercise involves analyzing a graph data structure which contains nodes that “depend on” other nodes. A graph is represented as direct dependencies between nodes: The objective is to find all … Continue reading

Posted in Swift | Tagged , | 1 Comment

DRY Fusion data munging kata in Swift

I worked through one of Dave Thomas’s programming exercises, called a kata, and pushed my Swift 2.2 code to GitHub. The code shows how to apply the Don’t Repeat Yourself (DRY) principle to two similar but different data processing programs. The end result of … Continue reading

Posted in Swift | Tagged , | 1 Comment

Higher-order functions in Swift

This article reviews some very useful higher-order functions available in Swift’s standard library, by showing a simplified implementation of each function. Along the way, I’ll explain how all of the higher-order functions are based on a single loop. Let’s get higher Similar to how a rock … Continue reading

Posted in Swift | Tagged , | 3 Comments

Creating ASCII art in functional Swift

This article explores an iOS app, written in a functional Swift style, that converts an image to ASCII art. For example, when given the famous Lenna photograph… …it creates a string that, when printed, looks something like this… Zooming into … Continue reading

Posted in Swift | Tagged , | 5 Comments

Zipping two lists in Haskell

Studying a pure functional programming, such as Haskell, can be an eye-opening experience. The standard library in Haskell provides a zip function, which combines the elements of two lists into a single list of tuples. I decided to implement my own version, named zip … Continue reading

Posted in Uncategorized | Tagged ,

Caesar cipher in Swift

I posted a Swift project to GitHub that implements the Caesar cipher, which was the encryption technique used to protect Julius Caesar’s personal correspondence. It’s a straightforward algorithm that maps each letter in the alphabet to another letter. The code also … Continue reading

Posted in Swift | Tagged , | 2 Comments