vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

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 be almost a class.

At least Swift isn't one of those languages that forces you to start with a class no matter what. A class is a nice coding tool, and that's all.

Swift uses three access levels:
public (can be imported by other modules/frameworks)
internal (default, no import by other modules/frameworks))
private (access only within the defining source code)
If no access level is used, Swift defaults to internal.

Coming in the fall of 2015 ...
Swift2 replaces println() with just print() that has a newline default. There are some other syntax changes and a much improved error handling.
The good news is, there will be a Swift 1-to-2 migrator utility to change Swift1 syntax to Swift2 syntax.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Best to use module os ...

''' file_splitext.py
get a given file's extension
'''

import os

filename = "myfile.exe"
name, extension = os.path.splitext(filename)
print("name = {}  extension = {}".format(name, extension))

''' result ...
name = myfile  extension = .exe
'''
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

A new business was opening and one of the owner's
friends wanted to send him flowers for the occasion.
They arrived at the new business site and the owner
read the card, "Rest in Peace".

The owner was angry and call the florist to complain.
After he had told the florist of the obvious mistake
and how angry he was, the florist said, "Sir, I'm
really sorry for the mistake, but rather than getting
angry you should imagine this. Somewhere there is a
funeral taking place today, and they have flowers
with a note saying, 'Congratulations on your new
location.'

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

One more function example tested on the Swift playground ...

// recursive function ...
// n changes so use var n
func factorial(var n: Int) -> Int {
    // use the very handy ternary expression "? :"
    // if n == 0 then 1 "exit condition"
    // else n * factorial(n - 1) "recurse with lower n"
    return n == 0 ? 1 : n * factorial(n - 1)
}

println("factorial(5) = \(factorial(5))")   // factorial(5) = 120
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Some experiments in the Swift playground ...

    String(255, radix: 2)              // "11111111"
    String(255, radix: 16)             // "ff"
    String(format:"hex 255 = %X", 255) // "hex 255 = FF"
    var binValue = 0b0011              // 3
    var hexValue = 0xff                // 255
    String(0xff, radix: 10)            // 255
    0b0100                             // 4
    0b0100 << 2                        // 16
    sqrt(3.14)                         // 1.772004514666935

    // cmd click on sqrt to get list of math functions
    // option click on any object name for declaration info

A note of caution:
Don't have two playgrounds running at the same time, your Apple computer is likely to freeze up!

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Laws are just a bunch of words left open to the interpretation of hired experts. After all, torture is against the law, yet it was conveniently interpreted by some hired lawyer to be okay in special circumstances.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
// using formatted values string via % specifier
var avgTemp = 66.844322156
// Objective-C NSString and Swift String are interchangeable
var sf = String(format:"average = %.2fF", avgTemp)

println(sf)  // average = 66.84F

let total = 74.89
let tax = 5.71
let city = "Minden"
var percent = 100.0 * tax/total
let sf2 = String(format: "%@ salestax = %0.2f%%", city, percent)

println(sf2)     // Minden salestax = 7.62%

Tested out on the Swift playground. Part of the Xcode IDE.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

There is still room on the roof for stickers!

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

An old lady came across a magic lamp one day and the genie told her he
would grant her three wishes. She wished for youth, which she recieved,
and she wished for fortune, which was also granted, but she couldn't
think of a third wish.
One day, as she was relaxing by her pool, she saw her dog playing in the
yard and she thought of her third wish. She told the genie, "My dog,
Fido, has always been so good and faithful. I wish for him to be a
young, handsome man for me to marry."
There was a puff of smoke and a young, handsome man stood before her.
The genie then vanished.
The woman couldn't believe her eyes. "Fido is that you," she said in a
soft voice."
"Yes, it's me," said the man, "and aren't you sorry you had me fixed."

XP78USER commented: You made me fell off my chair +0
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

My mother never saw the irony in calling me a son-of-a-bitch.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Apple executive Craig Federighi announced that Swift will be open source and made available for Linux later this year.

As far as vendor-written languages are concerned, there are some top notch folks working for Apple and also Google, developing a newer language has a reason.

Swift is being developed by Apple to work seemlessly with the Cocoa GUI toolkit, and to replace the misserable Objective C syntax (MHO). As far as I can figure it out, Steve Jobs' NEXT computer company developed the UNIX based NextStep OS using Objective C. This became OpenStep and when Steve returned to Apple, their new operating system based on OpenStep became OS X (for the Mac) and iOS (for iPad and iPhone).

Apple developed Xcode, an IDE to allow the development of OS X and iOS applications with the GUI toolkit Cocoa (also came in with OpenStep). Right now the problem is that all of these things are still developing, and the older version examples litter the internet and are not necessarily compatible with newer verions. A nightmare is born!

In the other camp, Google is developing the Go language for their search engine efforts and to trastically reduce compile time experienced with the present C++ compiler. Go does not have a GUI toolkit, but is available for most operating systems.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

No wonder the Ruble is down.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

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.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

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 out on 16sep2015 and with it the long awaited Swift2 version. The IDE contains a conversion option under the edit tab that will convert your Swift1 code to Swift2 syntax. The utility does a "Homer Simpson" type job.

ddanbe commented: Nice overview. +15
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

You can simplify the word_count function ...

// nicely simplified algo
// takes a slice of strings
// returns a word:frequency map
func word_count2 (words []string) map[string]int{
    word_freq := make(map[string]int)
    for _, word := range words{
        word_freq[word]++
    }
    return word_freq
}

I originally fleshed it out so you could follow the inner workings better.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

A programmer gets on a train to go to New York. There is a farmer in his green overalls next to him. To pass the time, the programmer decides to play a game with the guy.

"I will ask you a question and if you get it wrong, you have to pay me one dollar. Then you ask me a question, and if I get it wrong, you get ten dollars. You ask me a question first."

The farmer thinks for a while.

"Okay, what has three legs, takes ten hours to climb up a palm tree, and ten seconds to get back down?"

The programmer is confused and thinks long and hard about the question. Finally, the train ride is coming to an end. As it pulls into the station, the programmer takes out ten dollars and gives it to the farmer.

"I don't know. What has three legs, takes ten hours to get up a palm tree and ten seconds to get back down?"

The farmer takes the ten dollars and puts it into his pocket. He then takes out one dollar and hands it to the programmer.

"I don't know either."

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

A short test ...

# Python2
mylist = [x * 3 for x in range(2, 10, 2)]

# x leaks out and contains 8, the last value given to it
print(x)

... and ...

# Python3
mylist = [x * 3 for x in range(2, 10, 2)]

# x does not leak out
# gives NameError: name 'x' is not defined
print(x)
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Python3 offers function annotations to make code easier to understand ...

# function annotations (needs Python3) ...
# makes code easier to comprehend
# Python doesn't do anything with the annotations other than
# put them in an __annotations__ dictionary

def funk(x: int) -> float:
    return x*x/2

print(funk.__annotations__)

''' result ...
{'x': <class 'int'>, 'return': <class 'float'>}
'''
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Take a look at advanced unpacking made possible in Python3 ...

# advanced unpacking (needs Python3) ...
a, b, *rest = range(10)
print(a)     # 0
print(b)     # 1
print(rest)  # [2, 3, 4, 5, 6, 7, 8, 9]

a, *rest, b = range(10)
print(a)     # 0
print(b)     # 9
print(rest)  # [1, 2, 3, 4, 5, 6, 7, 8]

*rest, b = range(10)
print(b)     # 9
print(rest)  # [0, 1, 2, 3, 4, 5, 6, 7, 8] 

mylist = list(range(10))
size = len(mylist)//3
rest = mylist
newlist = []
for k in range(size):
    a, b, c , *rest = rest
    newlist.append([a, b, c])

print(newlist)  # [[0, 1, 2], [3, 4, 5], [6, 7, 8]]   
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Actually, in Python2, unlike Python3, the list comprehension leaks. So in this case x (as its last value) becomes available outside the comprehension.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

You are almost there, just have to create another function. I am not sure where the pen() belongs. Maybe something like this ...

import turtle

def triangle(tu, size):
    angle = 360/3
    for i in range(3):
        tu.forward(size)
        tu.left(angle)

def flagline(tu, length, num):
    tu.pen(pencolor='blue')
    for i in range(num):
        triangle (tu, length)
        tu.fd(length)    

ascreen = turtle.Screen()
tu = turtle.Turtle()

length = 100
num = 3
flagline(tu, length, num)

ascreen.exitonclick()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
''' tk_entry_textvariable2.py
set the content of an Entry widget via textvariable
use tk.StringVar() and set
'''

try:
    # for Python2
    import Tkinter as tk
except ImportError:
    # for Python3
    import tkinter as tk


root = tk.Tk()

# use this to set an initial value in Entry()
# to set value use v.set(value_string)
# to retrieve value use v.get()
v = tk.StringVar()
enter = tk.Entry(root, textvariable=v, bg='yellow', width=80)
enter.pack()

# set entry text
doh = "enter info"
v.set(doh)

# alternative ...
v2 = tk.StringVar(value="new info")
enter2 = tk.Entry(root, textvariable=v2, bg='green', width=80)
enter2.pack()


root.mainloop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Use this function to make sure that an integer value is entered ...

''' get_int23.py
an input function for integer values
'''

try:
    # allows the use of input() for Python2 and Python3
    input = raw_input
except NameError:
    pass


def get_int(prompt="Enter an integer: "):
    """
    this function will loop until a valid integer value is entered
    returns an integer number
    """
    while True:
        try:
            # successful return breaks out of the endless while loop
            return int(input("Enter an integer: "))
        except ValueError:
            print("Try again, value entered was not an integer value.")

# test
n = get_int()
print(n)
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Shows how to use a class for a record like structure ...

''' class_Persons101.py
create a list of instances of class Persons
from a space separated data file
'''

class Persons:
    # similar to a record
    def __init__(self, ni_number, name, age):
        # prefix dunder __ makes variable private
        self.__ni_number = ni_number
        self.__name = name
        self.__age = age

    def show(self):
        '''for a quick test'''
        # formating string
        sf = " ni_number = {}\n name = {}\n age = {}\n"
        return sf.format(self.__ni_number, self.__name, self.__age)


# format: ni_number firstname lastname age
data_str = '''\
55512 Bart Simpson 45
45622 John Smith 58
45813 Sven Soetebier 41
46231 Alicia Sands 27
'''

fname = "data123.txt"

# write test data file
with open(fname, "w") as fout:
    fout.write(data_str)

# read the data file back in and process
with open(fname, "r") as fin:
    person_list = []
    for line in fin:
        mylist = line.split()
        print(mylist)  # test
        # unpack the list
        ni_number, first, last, age = mylist
        name = first + ' ' + last
        # create a list of instances of class Persons
        person_list.append(Persons(ni_number, name, age))

print('-'*20)
# test one of the instances
inst1 = person_list[0]
print(inst1.show())


''' result ...
['55512', 'Bart', 'Simpson', '45']
['45622', 'John', 'Smith', '58']
['45813', 'Sven', 'Soetebier', '41']
['46231', 'Alicia', 'Sands', '27']
--------------------
 ni_number = 55512
 name = Bart Simpson
 age = 45
'''
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Advanced unpacking only works with Python3. Here is an example ...

# advanced unpacking ...
a, b, *rest = range(10)
print(a)     # 0
print(b)     # 1
print(rest)  # [2, 3, 4, 5, 6, 7, 8, 9]
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

If the developer used Python2 to develop your program, you might as well install Python 2.7 or you will have lots of errors. Python2 and Python3 are not compatible in many ways.

Some conversions can be made by using file 2to3.py, but it won't catch all changes (usually in C:/Python34/Tools/Scripts/2to3.py).

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

With Python2 input() uses eval() internally.
The eval function can potentially evaluate a statement to erase your harddrive.

With Python3 the former input() has been replaced with the functionallity of raw_input().

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Imagine termites taking over your computer.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

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

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

After a three-year long study, the National Science Foundation announced
the following results on Corporate America's recreational preferences.

  1. The sport of choice for unemployed or incarcerated people is
    BASKETBALL.
  2. The sport of choice for maintenance level employees is BOWLING.
  3. The sport of choice for front-line workers is FOOTBALL.
  4. The sport of choice for supervisors is BASEBALL.
  5. The sport of choice for middle management is TENNIS.
  6. The sport of choice for corporate officers is GOLF.

CONCLUSION: The higher you are in the corporate structure, the smaller
the balls you play with.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
# more or less accidentally putting a comma at the end like shown
# turns the integer value into a one element tuple
x = 123,
print(x)  # (123,)

# now this would give a
# TypeError: can only concatenate tuple (not "int") to tuple
print(x + 3)
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
''' switch_case101.py
a switch/case like statement to replace
multiple if/elif/else statements
'''

# make input() work with Python2 and 3
try:
    input = raw_input
except NameError:
    pass

def switch_case(case):
    return "You entered " + {
    '1': "one",                  # if
    '2': "two",                  # elif
    '3': "three",                # elif
    '4': "four"                  # elif
    }.get(case, "a bad number")  # else

num = input("Input a number between 1 and 4: ")
print(switch_case(num))
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The moral is that writing code that depends on order of evaluation is a bad programming practice in any language.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

I guess, we all need to just google and stop posting.

For some odd reason I could never get nzmath to go, all I got is a fistful of error messages.

The standard Miller Rabin isprime function is plenty fast for me. It is included in the "math/big" package in Google's Go language that I use use for high speed code.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

You have quite a few errors in your code.

Line 16 needs a "
Line 27 replace o with 0
Line 32 replace ! with 1

To see what's going on use a few temporary test prints.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Are you willing to pay for that book?

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

You could study Python, a "glue language" for C/C++. It is easy to learn and allows you to develop smaller projects quickly. This might keep you interested in experimenting with some of your own ideas.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Just trying to find out which of these five isprime functions is the fastest.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

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

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Ah, replace '^' with '**'. I am a little dense sometimes, now I see the humor ...

square_number = 4
grains = (2**square_number) - 1
if grains == 15:
    print("It's a fortnight!")

Note: square number 4 should have 8 grains on it

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

There is always room for one more word frequency program ...

''' Word_frequency2.py
experiments with string processing
preprocess the string and do a word frequency count

remove punctuation/whitespace with re
sort by frequency then word
dns
'''

from collections import Counter
import re
import pprint    


def sort_freq_word(tup):
    '''
    helper function for sorting of a list of (word, freq) tuples
    sort by looking at freq tup[1] first then word tup[0]
    the minus sign indicates reverse order sort for freq
    '''
    return (-tup[1], tup[0])


# sample text for testing (could come from a text file)
text = """\
A young executive was leaving the office at 6 pm when he found the CEO 
standing in front of a shredder with a piece of paper in hand. "Listen," 
said the CEO, "this is important, and my secretary has left. Can you
make this thing work?"

"Certainly," said the young executive. He turned the machine on, 
inserted the paper, and pressed the start button.

To the young executive's surprise the CEO said: 
"Excellent, excellent!" as his paper disappeared inside the machine. 
"I just need one copy."
"""

# convert text to all lower case
text = text.lower()

# use re to select words (remove punctuations and whitespace)
# \w+ means match 1 or more alphanumeric characters
# returns a list
words = re.findall(r'\w+', text)

# select the 10 most common words
# sorted by fequency (default)
common10 = Counter(words).most_common(10)

#print(Counter(words))
print("10 most common words sorted by frequency:")
for word, freq in common10:
    print("{:3d}
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Sort a listbox in Tkinter ...

'''tk_Listbox_sort1.py
load a Tkinter listbox with data
then sort the data
dns
'''

try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk


def sort_listbox(event):
    # convert the tuple to a list for sorting
    data = list(listbox.get(0, 'end'))
    print(data)  # test
    # delete contents of present listbox
    listbox.delete(0, 'end')
    # load listbox with sorted data
    for item in sorted(data):
        listbox.insert('end', item)
    sort_btn['text'] = "List has been sorted"


# the main window
root = tk.Tk()
root.title("")

# create a button to click for sorting
sort_btn = tk.Button(text="Click to sort listbox")
sort_btn.pack(pady=5)
sort_btn.bind("<Button-1>", sort_listbox)

# create a listbox (height in characters)
listbox = tk.Listbox(root, height=17, bg='yellow')
listbox.pack()

friend_list = [
'Steve', 'Tom', 'Mark', 'Adam', 'Alison', 'Ethel',
'Barb', 'Tiny', 'Tim', 'Pete', 'Sue', 'Zack']

# load the listbox
for item in friend_list:
    listbox.insert('end', item)

root.mainloop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Hmmm,

>>> square_number = 64
>>> (2^square_number) - 1
65
Slavi commented: I think he meant it as to the power of , not xor =) +6
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

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 the loop results and corrected a mistake.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

A few hundred years ago the glorious leader 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 glorious leader had one thing in common with the our present day leaders, he had no idea about basic mathematical concepts. So he 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? Here is a simple Python program to do the counting.

Corrected the code after looking at the loop result prints.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

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.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

A US Marine, a British soldier and a French Legionnaire are
captured by cannibals. They put up a grand fight, but there
were just too many and they were overwhelmed.

The cannibal chief says that they will be eaten, and their skins
used to cover the tribe's canoes, but since they had proven
themselves to be truly awesome fighting men, as a sign of
respect they would be allowed to kill themselves, rather than
the usual practice of being tortured to death.

The three were presented with a selection of implements with
which to do themselves in.

The French Legionnaire selected a knife, shouted, "Viva la
France!" and cut his own throat.

The British soldier chose a pistol, shouted, "God save the
Queen!" and shot himself in the head.

The US Marine picked up a big fork, and started stabbing
himself in the chest while shouting, "FUGG your canoe!!"

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Python is designed for readable code. If you want to write your entire code on one line, you have to pick another language. You can do it C.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

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.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

This explains the generator action a little better ...

// generator_fib5.go
//
// use a channel to simulate a generator
//
// channels are the pipes that connect concurrent goroutines
// send to channel syntax is "chan <- v"
// receive from channel syntax is "v, status := <-chan"
// (data flows in the direction of the arrow)
// receive status is true unless closed with closed(chan)
//
// more detailed info at:
// http://golang.org/ref/spec#Making_slices_maps_and_channels
// https://golang.org/ref/spec#Receive_operator
// online play at:
// http://play.golang.org/p/8kwaqcYWFq
//
// tested with Go version 1.4.2   by vegaseat  4may2015

package main

import "fmt"

// generator using a channel and a goroutine
func fib(n int) chan int {
    // create a channel
    c := make(chan int)
    // create an anonymous inner function
    // keyword "go" starts a goroutine
    go func() {
        x, y := 0, 1
        for k := 0; k < n; k++ {
            // send value x to the channel c
            c <- x
            // swap
            x, y = y, x+y
        }
        // close(c) sets the status of the channel c to false
        // indicates that the channel is now empty
        close(c)
    }()
    return c
}

func main() {
    fmt.Println("A Fibonacci generator via channel/goroutine:")
    // function fib() returns a channel
    // so fc would be of type "chan int"
    fc := fib(30)

    fmt.Println("The first 3 Fibonacci numbers:", <-fc, <-fc, <-fc)
    fmt.Println("The next  3 Fibonacci numbers:", <-fc, <-fc, <-fc)
    fmt.Println("The next  3 Fibonacci numbers:", <-fc, <-fc, <-fc)
    fmt.Println("The next …