View index.ts
import { both, converge, equals as eq, ifElse, not, pipe, toLower, type, keys, curry } from "ramda"
import { Either, left, right, isLeft, isRight, getOrElse } from "fp-ts/lib/Either"
export type Json = string|number|boolean|Date|JsonObject
interface JsonObject {
[x: string]: Json;
}
interface JsonArray extends Array<Json> { }
View Array2Dict.swift
func dict<T, U: Hashable>(from array: [T], getKey: (T) -> U) -> [U : T] {
var dict: [U : T] = .init(minimumCapacity: array.count)
array.forEach {
dict[getKey($0)] = $0
}
return dict
}
View main.swift
import Foundation
func encodeString(str: String) -> String {
return Array(str.utf16).map {
String(format: "%04x", $0)
}.reduce("") {
return $0 + $1
}
}
View main.swift
// Circular primes
// Problem 35
// The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.
//
// There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.
//
// How many circular primes are there below one million?
import Foundation
View AppDelegate.h
@import UIKit;
#import "PersistentStack.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end