Pure Programmer
Blue Matrix


Cluster Map

Selection

L1

This page is under construction. Please come back later.

Selection1.swift
#!/usr/bin/env swift;
import Foundation

// Begin Main
print("Start...")
if CommandLine.arguments.count != 3 {
	print("You need at least two command line arguments!")
}
print("Finish...")

exit(EXIT_SUCCESS)

Output
$ swiftc Selection1.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc Selection1.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation)
Selection2.swift
#!/usr/bin/env swift;
import Foundation
import Utils

// Begin Main
let x:Int = Int(CommandLine.arguments[1]) ?? 0
print("Start...")
if x > 10 {
	print("Greater than 10")
} else {
	print("Less than or equal to 10")
}
print("Finish...")

exit(EXIT_SUCCESS)

Output
$ swiftc Selection2.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc Selection2.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation)
Selection3.swift
#!/usr/bin/env swift;
import Foundation
import Utils

// Begin Main
let x:Int = Int(CommandLine.arguments[1]) ?? 0
print("Start...")
if x > 1000 {
	print("Greater than 1000")
} else if x > 100 {
	print("Greater than 100 but less than or equal to 1000")
} else {
	print("Less than or equal to 100")
}
print("Finish...")

exit(EXIT_SUCCESS)

Output
$ swiftc Selection3.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc Selection3.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc Selection3.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation)
Selection4.swift
#!/usr/bin/env swift;
import Foundation
import Utils

// Begin Main
let x:Int = Int(CommandLine.arguments[1]) ?? 0
switch x {
	case 1:
		print("One")
	case 2:
		print("Two")
	case 3, 4:
		print("Three or Four")
	default:
		print("Just don't know!")
}

exit(EXIT_SUCCESS)

Output
$ swiftc Selection4.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc Selection4.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc Selection4.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc Selection4.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc Selection4.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation)
Selection5.swift
#!/usr/bin/env swift;
import Foundation
import Utils

// Begin Main
var x:String = Utils.substr(CommandLine.arguments[1], 0, 1)
x = x.lowercased()
switch x {
	case "a", "e", "i", "o", "u":
		print(Utils.format("{0:c} is a vowel", Utils.ord(x)))
	case "y":
		print("y is sometimes a vowel")
	default:
		print(Utils.format("{0:c} is a consonant", Utils.ord(x)))
}

exit(EXIT_SUCCESS)

Output
$ swiftc Selection5.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc Selection5.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc Selection5.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc Selection5.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc Selection5.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation)
swift

Questions

Projects

More ★'s indicate higher difficulty level.

References