     public mutating func insert(str: String) {
         head.extend(str)
     }
+    /// Delete the last character of `head` if non-empty
+    public mutating func backspace() {
+        dropLast(&head)
+    }
+
+    /// Delete the first character of `tail` if non-empty
+    public mutating func delete() {
+        dropFirst(&tail)
+    }
+
+    /// Deletes all text in `Editor`
+    public mutating func clear() {
+        head = ""
+        tail = ""
+    }
+
+    /// Deletes all text in `head`
+    public mutating func clearHome() {
+        head = ""
+    }
+
+    /// Deletes all text in `tail`
+    public mutating func clearEnd() {
+        tail = ""
+    }
+
+
+    /// Remove the first character from `str`
+    private func dropFirst(inout str: String) -> Character? {
+        return !isEmpty(str) ? str.removeAtIndex(str.startIndex) : nil
+    }
+
+    /// Remove the last character from `str`
+    private func dropLast(inout str: String) -> Character? {
+        return !isEmpty(str) ? str.removeAtIndex(str.endIndex.predecessor()) : nil
+    }
 }

        return head + tail
    }

    /// Insert a new character at the end of `head`
    public mutating func insert(char: Character) {
        head.append(char)

    /// Construct an empty `Editor`
    public init() {
    }

    /// Construct an `Editor` from `str` placing cursor at home
    public init(str: String) {
        tail = str
    }


    /// The prefix of the string
    public private(set) var head = ""
