The Swift computer language is the brainchild of a number of Apple associates. In my humble opinion it shows some nice features, but also some warts. Part 1 (constants, variables, strings, tuples, arrays) explores a number of the features to give you a taste of the language. I hope I can follow this soon with part 2 (dictionaries, loops, if/else, switch/case,.functions, classes) Even if you don't have an Apple computer, you can educate yourself using the Swift computer language. Just go onto the **Swift online playground** at **swiftstub.com** and start typing Swift code, enjoy the experience! Note: Xcode 7.0 came …

Member Avatar
Member Avatar
+2 forum 27

Part 2 of exploring/tasting the Swift language takes a look at dictionaries; process flow controls like loops, if/else and switch/case; functions and sorting. I hope I can follow this up with part 3, a closer look at class operations.

Member Avatar
Member Avatar
+2 forum 23

In part 4 of tasting Swift, we explore structures. Swift has added some interesting features to structures like defaults, methods, multiple init(). This way struct objects come close to class objects with a little less overhead. As an option, methods can be added externally too. Take a look! Down the road there may be a part 4, exploring some odds and ends. Remember, Swift uses three access levels: public (least restrictive) internal (default) private (most restrictive) If no access level is used, Swift defaults to internal.

Member Avatar
Member Avatar
+1 forum 6

Like most modern languages Swift has sets and set operations. Here is a quick look. Coming in the fall of 2015 ... Swift2 replaces println() with just print() that has a newline default. The sort of thing that Python3 did to print(). There are some other syntax changes. Good news, there will be a Swift 1-to-2 migrator utility to change Swift1 syntax to Swift2 syntax.

Member Avatar
Member Avatar
+1 forum 1

Part 3 of the taste of Swift explores class objects in Apple's Swift language. A class allows you to group methods (class functions) together that belong together. Class Person groups some information of people working in an office. Class Pay inherits class Person and adds pay information. Class File groups file read and write methods. By convention class names start with a capital letter. Once a class is written it can be inherited by another class which eliminates a lot of extra code writing. Part 4 will talk about a related object, the structure. Swift has elevated the structure to …

Member Avatar
Member Avatar
+1 forum 5

A little experiment with custom sorting the result of a word frequency count using Google's Go language.

Member Avatar
Member Avatar
+2 forum 2

Just a couple of number tricks to check Go's mathematical abilities. If you have more, let's show them here.

Member Avatar
Member Avatar
+2 forum 1

The story has it that a few hundred years ago the ruler of a big country wanted to reward the creator of the chess game. The creator of the game simply wanted one grain of rice put on the first square of the chessboard, two grains on the second, then doubling it for every remaining square. The ruler acted surprised by the humble request, had his helpers bring a bag of rice and started to fill the squares. Did the creator of the chess game get a decent reward? Let's check it with some Go code. Note: I printed out …

Member Avatar
Member Avatar
+2 forum 5

Again, calculate the minimum number of bills or coins required for a given amount of money (change). This time we will use a Go map instead of a csv string converted to a structure.

Member Avatar
+0 forum 0

This Go snippet calculates the minimum number of bills or coins needed for a given amount of money (change) requested. The program also gives the denomination and number. US curency is used in this example, but can be changed to another currency.

Member Avatar
+1 forum 0

Another translation of one of my Python snippets. This function will return a slice of consecutive prime numbers from 2 to a given value limit. In Go the 'int' type (int32) will go as high as 2147483647, but you can replace 'int' with 'uint64' and go as high as 18446744073709551615.

Member Avatar
+1 forum 0

Generators are rather familiar objects in Python. Generators supply data on demand. Using Go you can create a generator with a goroutine and a channel. Here the goroutine is an anonymous function within a function, simple to implement.

Member Avatar
Member Avatar
+0 forum 1

Another little adventure into Go coding. This time a slice (a Go open ended array) of structures is used as a record for some data processing. For those who miss the ; at the end of a line of code, you can use them, but the lexer of the compiler will put them in for you. Go slices are simpler to work with and faster than traditional arrays, even though they use arrays as a backbone. Go was written for efficiency and speed of compilation in mind, it is intolerant of unused imports and unused variables. The reason you will …

Member Avatar
Member Avatar
+1 forum 3

Some folks go on vacation around the Easter holidays, so it would be nice to know when Easter happens in the years ahead. I had this as a Python snippet in my "oldies, but goodies" file and translated it to Go. It was actually quite easy in this case, and a good IDE like LiteIDE helped a lot.

Member Avatar
Member Avatar
+0 forum 1

This time just a simple example of grading scores (0 - 100) with letters (A - F). Two approaches are presented, one using switch/case in an "on the fly" function, and the other uses the score as an index to a string of letters F through A.

Member Avatar
Member Avatar
+1 forum 1

Reading the content of a web page with a given URL is pretty simple with Go. Here we defer the closing of the response body (at an early point, so we won't later forget) until the program exits.

Member Avatar
+0 forum 0

Use Google's modern Go language (aka. golang) to convert a denary number (base 10) to a roman numeral. Just a good exercise to explore Go's map, slice, sort and for loop features. Note that in Go the **:=** is shorthand for assigning a type (by inference) and a value to a variable. A slice is like an array that can grow, and a map is a key indexed list. Go has only the for loop, but the syntax is very flexible and can accomplish all the usual loop duties.

Member Avatar
+2 forum 0

The End.