<commit_before>func generatePermutations (var n : Int, var a : [Character]) {
    if (n == 0) {
        println("".join(a.map{"\($0)"}))
    } else {
        for i in 0...n {
            generatePermutations(n-1, a)
            a = swap(a, n % 2 == 0 ? i : 0, n)
        }
    }
}

func swap (var a: [Character], i : Int, j : Int) -> ([Character]) {
    var saved = a[i]
    a[i] = a[j]
    a[j] = saved
    return a
}

var word = "1234"
generatePermutations((countElements(word) - 1), Array(word))<commit_msg>Added anagrams for Swift<commit_after>#!/usr/bin/env xcrun swift

import Foundation

func generatePermutations (var n : Int, var a : [Character]) {
    if (n == 0) {
        println("".join(a.map{"\($0)"}))
    } else {
        for i in 0...n {
            generatePermutations(n-1, a)
            a = swap(a, n % 2 == 0 ? i : 0, n)
        }
    }
}

func swap (var a: [Character], i : Int, j : Int) -> ([Character]) {
    var saved = a[i]
    a[i] = a[j]
    a[j] = saved
    return a
}

if (Process.arguments.count != 2) {
    println("Exactly one argument is required");
    exit(1)
}

var word = Process.arguments[1]
generatePermutations((countElements(word) - 1), Array(word))

{'fraction_non_alphanumeric': 0.1785414920368818, 'fraction_numerical': 0.019279128248113998, 'mean_word_length': 2.2534059945504086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5731148', 'n_tokens_mistral': 462, 'n_tokens_neox': 433, 'n_words': 120}