Skip to content

rosslebeau/ouroboros

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

ouroboros

This is a Swift/Objective-C ouroboros.

An ouroboros is a type of quine where the programs will print each other in a loop - in this case, the Swift code prints the Objective-C program, and the Objective-C program in turn prints the Swift program. They can loop forever, producing exactly the same source code for each other.

I wrote this as a celebration of Swift 3 being officially released, since these are two languages that are near and dear to my heart. I hope you enjoy it!

##How to use this:

###Swift

Simply run

swift ouroboros.swift to obtain the Objective-C code.

###Objective-C

Compile the Objective-C source with this command

clang -fobjc-arc -F/System/Library/Frameworks ouroboros.m -o objc_ouroboros

then run it like this to obtain the Swift code

./objc_ouroboros

###Writing to File from Command Line

You can redirect the output of a program into a file like this

swift ouroboros.swift > ouroboros.m

and

./objc_ouroboros > ouroboros.swift

About

A Swift/Objective-C Ouroboros

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published