Last modified: 2019-04-20 17:30:01

What is this?

If an answer to an email is generally applicable, it will be answered here, rather than as a direct response. Send me an email as outlined in the first entry, and I will reply by making an FAQ entry here. Obviously you should check here before sending the email to see if the question has already been answered.


General FAQs will be answered here.

2022.01.01 09:01 How do I use this?
2019.04.20 16:50

Q.42 define the instance of Eq that has the natural semantics with the addition that A is equal to C 0 and D [], and B is equal to C 1.

what is the purpose of the instance Eq? does the fact that  A or B or C int or D[abc] are all under data type AB not imply they are all already equivalent data types? if not what kind of instance would prove that A is equal to C 0 if a any other data type?

I think you need to revisit the role of type classes, and try things like :t (==) and :info Eq
2019.04.20 16:50

Q41: Write the simplest Haskell function that has the following type signature:

p a i r L i s t   : :   ( a−>b )−>( b−>c )−>[ a ]−>[ ( b , c ) ]

are we supposed to create our own functions for (a->b) and (b->c)? or does it not matter if we write the functions or use haskell functions like sum / product? I ask because it says the simplest function and i do not wish to lose marks on the exam if I write my own functions.

It doesn't matter what the parameter functions do, as long as they have the domain and range as specified. Why would you write functions for them? You are asked to write a function that takes parameters of the particular types and return the appropriate result. The fact that you don't know the types of a, b, and c really restricts what code you can write that will match the signature. Apart from gratuitously adding calls to id, or constructing data structures and deconstructing them, there is actually only one function this can possibly be.
2019.04.20 14:30

In the slides for Professor Ufkes' lecture slides it says that infix is the only concrete representation that requires parentheses, but in Dr. Mason's slides his prefix slide has parentheses. For showing the minimum character concrete representation, which do we go by?

And on the same note, when dealing with a tree that has either 1 or 3 leaves at a certain node, do we treat this the same as dealing with a node with 2 leaves? ie.

    +
|   |   |
1   2   2

If this were postfix, would this just be 1 2 2 + or would we need to do something like (1 2 2 +) or perhaps 1 2 + 2 +

For prefix, we will accept either no parentheses (if the arity is correct), or every operator parenthesized (allowing variable arity).

In the example you show, the first one is wrong, because you can't know the arity. The second one is also wrong, although the reverse (+ 1 2 2) is generally how prefix is done. The third one is correct, because + has fixed arity of 2.

2019.04.20 01:36
Obj.call(p1,{:moveDelta,3,1})
for the line above what is moveDelta? I could not find any internet resources on this as all I could find was copies of this question from stack overflow and your course website. secondly:
def new(), do: spawn(MODULE,:init,[]).
what is the expected purpose of the above method? also if the purpose of this is to create a pawn why doesn't init handle the creation alone?
This is emulating objects with processes. :moveDelta is a symbol (i.e. like a string literal, except more efficient to compare). new just creates an object; init calls new because that's what functional decomposition is! Regardless, we decided that we didn't cover processes completely enough to ask that question.
2019.04.16 15:47 For Q40 in your test bank, where it says to write a function called fold for each language, you provide an example in a javascript-like language. Are those two lines of code all that we would need to write? Or would we have to fully write out the fold method if given this question?
This is an example of a use of the fold function.... not a definition. You would have to write the actual fold function.
2019.04.11 21:17 I recently made a commit using fossil and in the timeline it says that the commit was made at 12:54 tomorrow. Is there a way for me to fix this?
Fossil reports times as UTC (also known as GMT) time. Not to worry.
2019.04.05 13:02 I have the following code I got from Prof Ufkes' slides:
data Pt = Pt3 Float Float Float
 | Pt2 Float Float deriving (Show)
instance Num Pt where
 (Pt2 x1 y1) + (Pt2 x2 y2) = Pt2 (x1 + x2) (y1 + y2)
 (Pt3 x1 y1 z1) + (Pt3 x2 y2 z2) = Pt3 (x1 + x2) (y1 + y2) (z1 + z2)
 (Pt2 x1 y1) - (Pt2 x2 y2) = Pt2 (x1 - x2) (y1 - y2)
 (Pt3 x1 y1 z1) - (Pt3 x2 y2 z2) = Pt3 (x1 - x2) (y1 - y2) (z1 - z2)
 (Pt2 x1 y1) * (Pt2 x2 y2) = Pt2 (x1 * x2) (y1 * y2)
 (Pt3 x1 y1 z1) * (Pt3 x2 y2 z2) = Pt3 (x1 * x2) (y1 * y2) (z1 * z2)
 abs (Pt2 x y) = Pt2 (abs x) (abs y)
 abs (Pt3 x y z) = Pt3 (abs x) (abs y) (abs z)
 signum (Pt2 x y) = Pt2 (signum x) (signum y)
 signum (Pt3 x y z) = Pt3 (signum x) (signum y) (signum z)
 fromInteger n = let a = (fromInteger n) in Pt2 a a 
 fromInteger n = let a = (fromInteger n) in Pt3 a a a
When I load it into ghci I get the following error:
*Main> :reload
[1 of 1] Compiling Main             ( Foo.hs, interpreted )

Foo.hs:14:2: Warning:
    Pattern match(es) are overlapped
    In an equation for ‘fromInteger’: fromInteger n = ...
Ok, modules loaded: Main.
*Main> (Pt2 1 2) + 4
Pt2 5.0 6.0
Why is this?
The constructors Pt2 and Pt3 both produce the same type, Pt. So the 2 definitions of fromInteger have the same name and same type signature, so they conflict.
2019.04.03 21:16 I received this error when I was trying to clone my fossil repository for the Rust assignment. Would you by chance know what happened? included image showing error with expired SSL certificate.
This appears to be windows being super-agressive about expiring SSL certificates. I have verified the certificate and it is good until the end of June. Therefore you can simply say "always" accept the certificate, and things should proceed normally.
2019.04.02 23:03 In the to_indices() function in testing.rs the third line is currently:
let mut indices : Vec = cards.map(|card| deck.iter().position(|&r| r == card).unwrap()+1).collect();
I would like to request that we are allowed to remove the +1 after unwrap(). We have built out the program with 0 indexing and this causes problems when testing the program.
No, the specification is the same for all versions of the assignment. Of course you can do whatever you want in your code, such as subtracting 1.
2019.04.01 00:18 I was wondering if we're allowed to edit the testing.rs file as in add our own unit test cases to it? Also, whenever I commit the changes, I just want to clarify if it's submitting my changes for both main.rs and testing.rs files? The marker will use the testing.rs file that I submit to grade the assignment right?

Yes, edit the testing.rs file if you want, but I recommend adding your tests at the bottom or top, rather than intermingled through the file. This will make merging easier for the marker. You could also add a:

mod my_testing;
line to the main.rs file, and then put your tests in the my_testing.rs file (if you do this, don't forget to say fossil add src/my_testing.rs once to tell fossil you care about this file.

Yes, every time you do fossil commit all the files in the working directory that fossil knows about will be sent to the course repository.

2019.03.31 18:57 I am currently writing the rust project for cps506 I wish to get bonus marks for shuffling the cards, however it seems to generate random numbers an external dependency is required May I modify the dependency file to import this library?
Yes, you may add a random number generator crate to the dependencies in the Cargo.toml file. I have added a new item to the A4 web page to clarify this.
2019.03.29 09:04 My assignment 2 repository was removed and replaced with a Marks.txt. Is this the correct fashion of marking? However Marks.txt has blanks in all the marking categories. Does this mean I received no marks or does it mean it is still being marked?

Don't worry, your repository hasn't been removed!

One of the reasons we are using fossil is that fossil never deletes anything! Anything! Once your "fossil commit" has shown up on the fossil web page, it's there, until or unless the SCS machine room is destroyed.

What you see is a second "branch" in the repository, a branch called "marking". When you look at the "Files" tab, if you only see the "Marks.txt" file, then it has not yet been marked. If you click on the "trunk" button, you'll see your repo, intact.

When the marker marks the assignment, they will merge the marking branch into the trunk, and update the "Marks.txt" file.

In your working directory, you can move between the branches by saying:

      fossil update marking
    
or
      fossil update trunk
    
"trunk" is the name of the main, published, thread. Branches are usually used for bugfixes or optional features. We're using them to facilitate marking.

Once it's marked, the marking branch will have been merged into the trunk, and all the files will be visible on truck.

2019.03.28 18:06 I wanted some clarification for the assignment. Do we modify the tests.hs or do we write our own code from scratch?
As it says somewhere, add to the test file I provided you. Add either at the beginning or the end so that if we add more tests for marking purposes there is less chance of a conflict.
2019.03.27 12:48

I am having trouble getting your testing file to work with my code (probably due to my code having a different structure) and I was wondering if you could shine some light on what is wrong?

My with_permutation takes a vector of unsigned integers as specified by the instructions: "fn with_permutation(deck: Vec)"

as well, my format_game takes in a couple of strings that I then print to screen: "fn format_game(str_north:String, str_west:String, etc.)"

I am unsure if this is how you expect these two methods to be setup or not?

I have updated the assignment definition to make clearer that the with_permutation function should return a "game object" and that the format_game should take a single parameter "game object" and return a string. Where "game object" is (as in the previous assignments) whatever you want it to be, but it's a single value (most likely a struct in Rust, a data type in Haskell, a tuple in Elixir, and an instance of the BidBridge class in Smalltalk).
2019.03.26 19:40 When I clone my fossil, it's empty (i.e. even
fossil time -R my_name.fossil
says there is nothing.
That is because you initially entered a bad password and then when it re-prompted, you entered it correctly. This is a fossil bug and has now been fixed (for those that compile fossil from source) but the download files haven't yet been updated because those versions are only released every few months. Just remove that file that was created and re-clone - should be fine.
2019.03.26 19:36 When I open the fossil for assignment 3 on the accounts tab on the cps506 website, it shows a completely empty fossil with no commits and no branches.
Click the login button in the top right. Fossil can allow anonymous cloning of repositories, but I've disabled that for assignments, for obvious reasons. So usually it prompts you to log in, but sometimes (for reasons I don't completely understand) it shows the anonymous result, which is empty for the reason above.
2019.03.25 00:11 I am trying to add my Ownership.txt file to my Assign3 folder but fossil does not recognize it and when I commit it does not commit the ownership file to my repository. Even after I have created the file in the directory and added text to it, when I commit it says nothing has changed.
Type:
fossil add Ownership.txt
and then commit.
2019.03.17 22:53

I'm confused about no trump hands. The instructions state that: A "no trump hand" means you have no singletons or voids and no more than 1 doubleton, and stoppers in all suits (so the suit has an ace or king, or a queen with 2 other cards, or a jack with 3 other cards).

How is it possible to have one double-ton and stoppers in all suits? My understanding of the instructions is that a stopper is at least 3 cards: ace, king or queen plus 2 more cards. Or it can be 4 cards: jack + 3 more cards.

Read the difference between your 2 paragraphs. The doubleton could be headed by an Ace or a King. If you have 3 cards in a suit, you must have at least a Queen, and so on.
2019.03.14 23:16 For the tests that we write, do we add our tests methods to the test file on Fossil? Or do we submit a new test file?
Add them either to the end or the beginning of that test file. Do not create a new test file or remove tests (except that you can/should correct test N3).
2019.03.13 18:28 In N3, isn't the bid 2S rather than 1S because south can go to next level?
No... they can go to the next level, but unless they have 13+ points they won't skip a level. If they had less than 10 points, they cannot, so if Clubs was their best suit, with 11 points they would go to 2C, but with less than 10, they'd simply raise partner (or pass if less than 6).
2019.03.13 18:14 In test N3, I don't understand why the bid is 2D instead of 2S because south has 11 points, north opened already, and no-trump hand is false.
You're correct. As was posted on D2L, there is an error in the test case N3 as South's best suit is Spades, so the bidding should be:
South West North East
Pass Pass 1D Pass
1S Pass Pass Pass
Declarer: South
Sorry I forgot to say that here, too. Now I have!

2019.03.13 15:58 I do not understand what is a no trump (NT), and when it is played. Under what conditions does it exist and when can it be played?
A No Trump hand is described in 5.8. It means a balanced hand that will be able to win tricks on the basis of high cards rather than distribution. When to bid is decribed in 5.9.3, 5.11.1, 5.11.2, 5.12.1
2019.03.13 15:45 In the test N2, East opens with a level 2 bid. How is that even possible?

In particular, as stated in part 5.16, the bidding is independent between the two teams. Therefore, East would only consider the bids of West.
Because Clubs are lower than Diamonds, so the lowest possible Club bid, over 1D is 2C. The description said "at the 1 level"; I've corrected it to say "at the lowest possible level (typically 1)".

The bidding is independent in the sense that East, for example, wouldn't take into account the suit that North bid, or the number of points it implies, but every bid must be higher than the previous bid, or Pass. In real bidding this is sometimes used by throwing in a bid purely to push the opponents too high, so they may not have enough bidding room to find their best contract - but this is irrelevant to us.
2019.03.13 15:03 In test N2, when East opens for its team (since West passed before), Why would it bid "2C"? East's longest suit is Hearts. Shouldn't that be its bestSuit to bid?
Because 5.9.2 and 5.9.4 say (indirectly) that you only bid hearts or spades if they are 5 cards or more. This is actually a standard rule in bidding, although the justification is beyond this assignment.
2019.03.11 10:18 I do not understand what is a no trump (NT), and when it is played. Under what conditions does it exist and when can it be played?
"No Trump" is what it says, there is no trump suit, so high cards matter more. Therefore, to open NT, you need more points, as described in 5.9.3. It is also useful as an answer to say, "I don't have support for your suit, but I have everything else covered, and have a moderately strong hand", as described in 5.11.1 and 5.11.2. It's also usedful (though irrelevant to us) in that a "game" bid in NT is only 9 trick (a bid of 3NT)s, versus 10 in hearts or spades, and 11 in clubs or diamonds.
2019.03.10 23:25 question about the Elixir assignment. In the Answering, (as shown in the pic below) Does "if you can do it at the same level" mean that the bid HAS to be at the same level as the currentBid? Or can it be higher than currentBid?
Has to be. See also the question from 2019.02.27 10:36 below.
2019.03.07 13:48 I was wondering if I could get another chance of submitting assignment x?
One of the real advantages to using a version control system to submit assignments is that you can commit any time you need to. Up to the due time, there will obviously be no penalty. Even if it is after the deadline, because the marker can see what was changed, there may be no penalty if it was a trivial change, and only a minor penalty if it was a small change.
2019.03.07 13:15 regarding the midterm I noticed there were questions on AST's but including find any posted resources on what each precedence rule is or where I could find them (for example whether all is pre or post fix)
As it says on the midterm page and the D2L announcement, this includes all the questions that might be relevant for the entire course, and some of the questions will only be relevant for the final exam.
2019.02.27 10:46 What do we declare as the declarer when all of the players pass during the first round?
   Declarer: None
2019.02.27 10:36 In regards to (5.11.2) on the assignment sheet, what does the assignment refer to when it says "If you have 10 or more points, if you have a no-trump hand, bid no trump; otherwise your best suit and you can go to the next level.". Specifically, what does "you can go to the next level" refer to? So if the best suit is clubs and the current highest bid is 1H, do we bid (2C or 3C)?
You would bid 2C. It you didn't have 10 points, then 5.11.3 would apply and then over 1H you could only bid your suit if it was Spades, because anything else would force you to go to the 2 level.
2019.02.26 17:22 The test classes have use a class called BridgeBid instead of BidBridge like the assignment says. Also they call a class-side method withPermutation: instead of an instance-side method.
Dr. Mason answers: Mea culpa! You can resolve the first problem by creating a BridgeBid class with a single, class-side, method:
new
    ^ BidBridge new
Code critic will likely give you a warning or two, but you can ignore them
You can resolve the second problem by adding a class-side method to your BidBridge class:
withPermutation: aCollection
    ^ self new withPermutation: aCollection
2019.02.26 15:20 the test I received after cloning runs this command " bbid := BridgeBid withPermutation: (1 to: 52).". However it return an error, I tested the class of the message passed to withPermutation " Transcript clear; show: ((1 to: 52) class)." and receive the class of an Interval. In the Assignment layout this method must accept an OrderedCollection or an Array. i an wondering if i am allowed to change the message to either of the 2 choices in the assignment layout.

Smalltalk programmers rarely use Transcript, because there are so many better ways to examine values. The easy way to find out the class of an expression is to inspect it. E.g. (1 to: 52) inspect or simply highlight the 1 to: 52 in any window and type command-i or control-i or type comand-p or control-p to print it. Inspect is used a lot more because you can explore the value.

As to how to work with intervals, they mostly work like collections, so do: collect: select: all work fine. In fact I'm hard pressed to find something you can't do with them, except store into them, and I can't imagine why you'd be wanting to store into the card permutation you are presented with. But, if you do need an Array for some reason, you can get an Array from an Interval called permutation with the expression: permutation collect: #yourself

2019.02.25 15:08 When/where is the midterm?
March 8th, 18:30-20:30, in various rooms in ENG-LG
2019.02.25 08:07 Also, I'm a bit confused on how to store each players hand with S H D C along with how writeStream printing works. Is the whole board just one string, or do you print the board based on each player separately line by line?
I would have a Hand class, instances of which hold the cards in a haand, and has methods that do the bidding. printOn: takes a stream and prints the hands and bidding on the stream, using methods like printOn:, nextPut:, and nextPutAll:. There are string streams, and the Transcript stream which outputs into a window. The tests produce a string because that is easiest to compare to.
2019.02.25 08:06 Step 2 in your instructions mentions that the "withPermutation" method takes a collection which is the order of the deck from numbers 1-52. You then mention that "The permutation will tell you which card goes in each position of the shuffled deck." So does this mean the method returns a collection such as an array with elements, ['KH' '10S' 'QC' '7C' ...]?
The method returns a game object that has the deal included, with the bidding done.
2019.02.25 06:45 For assignment 1, my partner and I both set up a fossil account without knowing about the partner option. Now we cannot hand in 1 project. Is there a way to fix this?
You're not the only one! Because the fossil environment setup was delayed we'll accomodate for Assignment 1. I will convert a private fossil into a shared fossil that is done by 2 people. The person whose repository you wish to submit should send an email, CC to the other student, telling me the situation. I will then make that private repository into a shared repository waiting for the second student to agree, and email you both to say that is done. Once that is done the second student's private repository will disappear so make sure you have everything in the first student's repository (verified using the fossil GUI on the account page) before asking me to make it a shared repository.
2019.02.18 22:27 How can I tell if my code has been submitted correctly?

Go to the account page and click on the "Fossil" button. Log in and if you click on timeline you should see something after dmason's check-in on February 6. If you don't, you have not committed successfully. Most likely you haven't committed at all with fossil. From within Pharo, you can save your package, which will update your Fossil working directory, but until you say fossil ci -m "some reason", it hasn't been saved in the fossil repository. Once you say fossil ci it will commit it to your local repository and then send it to the remote respository, where you can see it by clicking on the "Fossil" button.

If you're working with a partner and they can't see your changes, you are looking at the same problem.

2019.02.16 09:20 For the assignment 1, when writing test for my classes, do I write test for all methods of that class or do I only write test for only methods that return a value. I sure if get and set methods are expected to be tested also.
The general principle is "write tests for any non-trivial functionality". Setters and getters (in Smalltalk, methods called abc and abc: not etAbc and setAbc as they might be called in Java) are (generally) trivial functions, so would not have unit tests.
2019.02.12 20:33 Updated I have tried to log in to my fossil account and have changed my password 4 times and each time and I am unable to log in after closing a session. I am also working with a partner and she is able to access the fossil with no problem.
There was a problem when you used certain special characters to get the entropy of your password high enough. Sorry; fixed now!
2019.02.11 12:13 Fossil doesn't seem to work for me. The version installed on my Linux sub shell is 1.33.

1.33 is very old! (at least 3.5 years) More importantly, it's incompatible with the 2 series. The current version available to download from https://fossil-scm.org/index.html/uv/download.html is version 2.7. Sometimes other sources are not current - in particular Linux distributions.

Unfortunately, I don't use Windows for anything, so my ability to help is limited, but I will see what I can do.

2019.02.11 10:20 Any update on the make-up class?
Yes, it is in KHE127 on Friday, Feb 15, 18:00-20:00 - 2 hours after the regular class which will meet as normal.
2019.02.11 08:46 Is the fossil repo ready? Which methods are we meant to use for the bidding component? What format do you expect the unit tests to be in? How do we test if our bidding functionality is up to your standards?

Yes, the fossil setup is now working. See the Account link in the navigation box

As the assignment says, "Your BidBridge instance must have a withPermutation: method" and "Your BidBridge instance may have a play: method". Any other classes and methods are up to you. Unit tests should be broken down on a class-by-class basis, so for BidBridge there should be a BidBridgeTest that subclasses TestCase, etc.

The fossil includes quite a few unit tests. You could use Test-Driven-Design to implement the rest of your solution, but you don’t have to keep my tests (you can create your own that use the methods you chose to implement). The only tests that really should produce the correct results are the ones in BridgeBidTest, as they check that the required method produces the correct output.

2019.02.10 13:07 The rules for answering seem very complicated.
You are correct. Though still much simpler than a real player would do, they were needlessly complicated. They have been simplified.
2019.02.08 16:28 I just wanted some clarification as to whats happening. will be be having a 4 hour class next week or would we have one 2-4 and then another 6-8 or are we just going to have our normal 2-4 class?
This only applies to sections 1,2,6 (although others are welcome to attend). There will be regular class 2-4 on February 15th, and then an additional make-up class (to replace the February 1st class that was cancelled) from 6-8.
2019.02.06 12:47 When bidding, do we "place" cards in the centre? and would that mean that we have to re-calculate points of the hands for the next opportunity each player has to bid?
No, while bidding, your hands do not change. This means after the cards have been dealt, there will be no further changes to any hand. But this doesn't mean you should "save" the points counts... just recalculate as needed... efficiency is not an issue. (Execution efficiency is much less often an issue in the world than many programmers think!)
2019.02.06 12:46 Is there a set number of iterations we must bid? Or do we allow the bidding process to continue until there are 3 passes?
Just allow the bidding to continue until there have been 3 consequetive passes (making sure that everybody has had an opportunity to bid at least once!).
2019.02.01 12:50 I heard the ARC building is closed. Is there a class today?
I was just told that the ARC building is closed until further notice, so Dr. Mason's class is closed, but he'll be in his office to answer any questions.
2019.02.01 12:48 According to the assignment 1 description page, we have to implement a shuffling program and not any other elements of Bridge.
Actually, the shuffle is optional. Dealing the cards, printing out the result, bidding, and printing out the bidding are the major components.
2019.02.01 12:43 For the midterm and final exam, would the tests be on the computer or on paper?
They will be on paper. About 1/2 - 2/3 of the marks will be multiple-choice (but about concepts, not memorized definitions). The remainder will be short-answer programming problems - in 2 languages for the midterm, all 4 for the final.
2019.02.01 12:17 step 5 of the assignment (and therefore having trouble with the rest) as it seems to imply an artificial intelligence approach to the "bidding" process, and I can assume that that is beyond the scope of the course
No, you don't need AI. You need to read the whole description. The bidding as described is deterministic (or at least is intended to be, if you discover any ambiguity, please let me know).
I have updated the description to make it clearer, and hopefully made the numbering clearer so you can report any problems.
Also, realize that even if you don't get the bidding, if you get the rest and have good tests, you'll get at least 1/2 the marks, and you'll understand the language significantly better.
2019.01.30 10:33 Items 11 and 12 in the bridge bidding are a bit unclear.
Clarified.
2019.01.30 10:14 When might we expect some tests?
Probably this weekend.
2019.01.29 10:04 Do we need to validate inputs for the assignment (ie if there are more than 52 cards provided). I presume we do not?
There may be fewer than 52 elements in the array (which may be useful for debugging and tests), but all will be in the range 1..52 and unique. You can assume that.