It's UWAweek 38 (2nd semester, week 8)

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
113 articles posted by this person
Showing 113 of 471 articles.
Currently 15 other people reading this forum.


 UWA week 38 (2nd semester, week 8) ↓
SVG not supported 5:35pm Wed 18th Sep, Joshua N.

ANONYMOUS wrote This is not what Chris means. He means to not submit header files (e.g. you can't submit a header file you wrote). You still have to import header files or compilation will fail. Your code won't compile if you do this. This is what ...


SVG not supported 5:30pm Wed 18th Sep, Joshua N.

ANONYMOUS wrote You can make assumptions about any of the project requirements that are unclear. In the doc you are stating what you believe you are meant to do or what you believe the requirements are telling you to do. E.g. one assumption could be ...


SVG not supported 5:27pm Wed 18th Sep, Joshua N.

ANONYMOUS wrote No, I don't think so, since they represent the command line arguments. However, since it hasn't been clarified you can put whatever you assume in the doc.


SVG not supported 5:26pm Wed 18th Sep, Joshua N.

Answered here https secure.csse.uwa.edu.au run help2002?p np opt U275 hl white 20space


SVG not supported 5:24pm Wed 18th Sep, Joshua N.

ANONYMOUS wrote Possibly, but it is a bit ambiguous you could probably have an assumption in your assumption doc about it. This definitely has to be true. I believe the point 9 is stating that in the ml file the function definition has to come before t...


SVG not supported 11:16am Wed 18th Sep, Joshua N.

ANONYMOUS wrote Amitava said to use 'cc -std c11 -Wall -o output output.c'.


SVG not supported 9:51am Wed 18th Sep, Joshua N.

ANONYMOUS wrote Don't need to validate y 2 since it is an expression, but you do need to validate the assignment.


SVG not supported 6:43am Wed 18th Sep, Joshua N.

ANONYMOUS wrote Option d is wrong. You just had a lucky number choice where the result is the same. If you first divide by ten you perform integer division and so the result becomes 2409, modulo 100 gives 09, which is 9 in this case. A is correct. modu...


SVG not supported 6:22am Wed 18th Sep, Joshua N.

You don't need to do this. The arguments are "passed in" into the variables arg0, arg1, etc. This is what you are meant to do. np


SVG not supported 8:31pm Tue 17th Sep, Joshua N.

ANONYMOUS wrote I believe Chris intended students to actually parse the strings themselves. If you want confirmation, you will have to ask Amitava. Honestly, I don't think regex.h will make your life easier.


SVG not supported 5:01pm Tue 17th Sep, Joshua N.

ANONYMOUS wrote WSL stands for "Windows Subsystem for Linux". So Linux.


SVG not supported 3:37pm Tue 17th Sep, Joshua N.

Just multiply x by 1 in the code. e.g. x x 1; and the error warning will go away.


SVG not supported 3:34pm Tue 17th Sep, Joshua N.

Maybe my answer to this question will answer your question https secure.csse.uwa.edu.au run help2002?p np opt U344 hl arg0 Let me know.


SVG not supported 3:30pm Tue 17th Sep, Joshua N.

ANONYMOUS wrote I mean a lot of the advice given on the forum is based off the project requirements and clarifications Chris made, so it really depends on which advice you are talking about. A rule of thumb for assumptions is If you make an assumpti...


SVG not supported 3:19pm Tue 17th Sep, Joshua N.

ANONYMOUS wrote Seems good so far. Just make sure to delete the output.c file and the executable when you are done.


SVG not supported 5:35am Tue 17th Sep, Joshua N.

ANONYMOUS wrote Answered here https secure.csse.uwa.edu.au run help2002?p np opt U278 hl website


SVG not supported 5:35am Tue 17th Sep, Joshua N.

ANONYMOUS wrote This is a statement, so yes. pqr will be zero so it won't matter. sas will cause the error, since there are two identifiers followed after each other in a statement, which is invalid syntax.


SVG not supported 8:33pm Mon 16th Sep, Joshua N.

ANONYMOUS wrote Hi sorry, you are right. I misread what he said. Thanks for letting everyone know.


SVG not supported 5:32am Mon 16th Sep, Joshua N.

This is invalid syntax. program A program is made up of zero or more program items. program-item A program item is either a statement or a function, a function can have zero or more identifiers. statement A statement is either an assignment or a pri...


SVG not supported 5:23am Mon 16th Sep, Joshua N.

ANONYMOUS wrote The file is temporary and will be deleted by your program. So, you can name it whatever you want (but make 110 sure the name doesn't and will not collide with other file names when run on other people's computers). However, the reaso...


 UWA week 37 (2nd semester, week 7) ↓
SVG not supported 2:22pm Sun 15th Sep, Joshua N.

ANONYMOUS wrote Write them to the file into their respective identifiers. E.g. arg0 is argv 2 assumption. I believe Chris said that you can assume the appropriate number of command line arguments are passed to the ml program https secure.csse.uwa....


SVG not supported 2:08pm Sun 15th Sep, Joshua N.

ANONYMOUS wrote You can't pass "integers" to a function; the arguments are always doubles, so even if you pass 2, because the argument was defined to be a double, it will become 2.0. Every time you see a constant number, just put (double) in front of...


SVG not supported 10:45pm Sat 14th Sep, Joshua N.

ANONYMOUS wrote Amitava needs to answer this one. From project specification "Your submission will be examined, compiled, and run on a contemporary Ubuntu Linux or macOS platform. Your project only needs to execute successfully on one of these platfo...


SVG not supported 10:43pm Sat 14th Sep, Joshua N.

ANONYMOUS wrote Hi, in both cases, the variables would be considered global since they are not located inside of a function.


SVG not supported 10:40pm Sat 14th Sep, Joshua N.

Hi Yuxuan You are allowed to make assumptions and submit them with your code submission. I believe the original intension was that all expressions will be valid, so you don't need to check them. Statements in a function should be 1 tab and everything ...


SVG not supported 10:16pm Sat 14th Sep, Joshua N.

ANONYMOUS wrote Yea that's fine as long as you delete all the files you create. The only thing that needs to be a single file is the runml program itself.


SVG not supported 7:20am Sat 14th Sep, Joshua N.

https teaching.csse.uwa.edu.au units CITS2002 projects project1-syntax.php


SVG not supported 7:13am Sat 14th Sep, Joshua N.

No ml doesn't allow passing a function to a function. It is too complex for this project, and I don't believe it will be covered in the unit.


SVG not supported 7:10am Sat 14th Sep, Joshua N.

ANONYMOUS wrote Yes, the ml syntax allows it.


SVG not supported 7:09am Sat 14th Sep, Joshua N.

ANONYMOUS wrote Yes, otherwise if you have already done it Amitava said you can state the assumptions you made in a file. So, you can do either, just state what assumption you made.


SVG not supported 8:21am Fri 13th Sep, Joshua N.

ANONYMOUS wrote Best to ask Amitava.


SVG not supported 8:21am Fri 13th Sep, Joshua N.

ANONYMOUS wrote Yes


SVG not supported 8:21am Fri 13th Sep, Joshua N.

ANONYMOUS wrote No, because we are assuming expressions are valid and don't need to be checked.


SVG not supported 7:20am Fri 13th Sep, Joshua N.

ANONYMOUS wrote Best to ask Amitava.


SVG not supported 7:20am Fri 13th Sep, Joshua N.

ANONYMOUS wrote Best to ask Amitava.


SVG not supported 7:14am Fri 13th Sep, Joshua N.

If you want to be 100 sure you can ask Amitava. You can always do something with var to remove the warning. Literally just do var var 1 and the warning will go away.


SVG not supported 10:43pm Thu 12th Sep, Joshua N.

ANONYMOUS wrote Tabs are a form of white space. More detail given here https secure.csse.uwa.edu.au run help2002?p np opt U351


SVG not supported 10:39pm Thu 12th Sep, Joshua N.

Best to ask Amitava for clarification.


SVG not supported 10:33pm Thu 12th Sep, Joshua N.

ANONYMOUS wrote Technically they're not considered "identifiers" just "variables". So, in other words, they're an exception to the rule. As stated in the project description "8.the variables arg0, arg1, and so on, provide access to the program's comm...


SVG not supported 10:31pm Thu 12th Sep, Joshua N.

ANONYMOUS wrote It does apply to comments. He made the change to make sure the project isn't too hard. From Oxford English Dictionary "white space n. (a) Typography the blank areas of a page or other piece of printed matter, as margins, gutters betwe...


SVG not supported 9:24pm Thu 12th Sep, Joshua N.

ANONYMOUS wrote Best to ask Amitava.


SVG not supported 9:20pm Thu 12th Sep, Joshua N.

ANONYMOUS wrote You are missing something. You replace the identifiers (in the ml file) arg0, arg1, arg2, etc. By the command line arguments that are passed to run ml. e.g. . runml somefile.ml 1 2 3 means that in the ml file the parameters will be initi...


SVG not supported 9:17pm Thu 12th Sep, Joshua N.

ANONYMOUS wrote If print appear outside a function in ml, then you put the print statements in main otherwise you'll get an error.


SVG not supported 9:16pm Thu 12th Sep, Joshua N.

I believe so, they would be two separate identifiers, but they would count towards "unique" identifiers since they have the same name.


SVG not supported 9:13pm Thu 12th Sep, Joshua N.

ANONYMOUS wrote Why can't the same identifier name be reused? After the function ends the program would believe it is seeing the identifier for the first time and so would initialize it to 0.


SVG not supported 9:11pm Thu 12th Sep, Joshua N.

ANONYMOUS wrote Yes. Otherwise, there would be no way to differentiate between a normal variable and a command line argument.


SVG not supported 9:10pm Thu 12th Sep, Joshua N.

ANONYMOUS wrote Just add return 0.0 to the end of your functions if they don't have a return statement.


SVG not supported 9:09pm Thu 12th Sep, Joshua N.

ANONYMOUS wrote I believe Chris said either in the forum or the project sheet that all statements must start at the lefthand most side of the file unless it is a statement in a function. Not sure where a comment could appear (because technically comme...


SVG not supported 9:04pm Thu 12th Sep, Joshua N.

It would. Or you can write an if statement in the c version of the ml file to change what is printed, then let c do the hard work. That would make the most logical sense. Since warnings can be errors and do something unintended. No guarantees about the...


SVG not supported 8:59pm Thu 12th Sep, Joshua N.

Yes, I forgot there are no "if" statements in ml, because there are no "if" statements, it would run forever. So, don't worry about recursion. Can't see the point in testing an infinite loop.


SVG not supported 8:50pm Wed 11th Sep, Joshua N.

ANONYMOUS wrote Hey guys, ml accepts whole numbers, there is no example in the ml file where there is a decimal point after a whole number, e.g. 2.0 would just appear as 2 in the ml file. I'm assuming as more decimal places are required they will be ...


SVG not supported 8:46pm Wed 11th Sep, Joshua N.

The syntax of ml does seem to allow recursion, shouldn't be hard to implement (since you just copy the function call into C).


SVG not supported 8:45pm Wed 11th Sep, Joshua N.

ANONYMOUS wrote Best to ask Amitava.


SVG not supported 8:45pm Wed 11th Sep, Joshua N.

Best to ask Amitava.


SVG not supported 8:43pm Wed 11th Sep, Joshua N.

Note there are no empty lines in ml, "empty lines" start with a .


SVG not supported 8:42pm Wed 11th Sep, Joshua N.

ANONYMOUS wrote It would be illegal. The syntax of ml doesn't allow the printing of statements.


SVG not supported 8:40pm Wed 11th Sep, Joshua N.

You wouldn't need to check mismatched brackets as Chris said expression checking isn't necessary. Yes, if 24.00, print as 24. if 24.5, print as 24.500000 Not sure but better to be safe than sorry and assume it can be as deep as it is in C.


SVG not supported 8:38pm Wed 11th Sep, Joshua N.

I would say it works as it does in c, and would return 0, so the outer print would return 1.


SVG not supported 8:37pm Wed 11th Sep, Joshua N.

Hi Trisha, Sorry for the delay. If no clarification is given, better to be safe than sorry and assume it is possible. This functionality is allowed within the ml syntax.


SVG not supported 8:36pm Wed 11th Sep, Joshua N.

ANONYMOUS wrote Hi unfortunately because Chris is now on leave, I'm not sure if the website will be released.


SVG not supported 8:35pm Wed 11th Sep, Joshua N.

ANONYMOUS wrote If no clarification is given, better to be safe than sorry and check the number of parameters.


SVG not supported 8:35pm Wed 11th Sep, Joshua N.

Identifiers and functions shouldn't have the same name. Syntax of ml allows this. You should be able to just copy the function call into c and it would work.


SVG not supported 8:30pm Wed 11th Sep, Joshua N.

You need to change the format string of printf so that you print the double without any decimal places. Answered here https secure.csse.uwa.edu.au run help2002?p np opt U245 hl integer I would say so. Some warning in C are straight up errors and res...


SVG not supported 8:27pm Wed 11th Sep, Joshua N.

ANONYMOUS wrote Yes, that seems correct.


SVG not supported 8:24pm Wed 11th Sep, Joshua N.

ANONYMOUS wrote Hi I don't believe empty lines are allowed in ml, all the sample files have no empty lines and instead use a comment to create an "empty" line.


SVG not supported 8:21pm Wed 11th Sep, Joshua N.

I believe it is fine to return zero if a function doesn't have a return value. Amitava please respond to the second question.


SVG not supported 8:19pm Wed 11th Sep, Joshua N.

ANONYMOUS wrote I think either is fine, but returning 0.0 is probably easier.


SVG not supported 8:19pm Wed 11th Sep, Joshua N.

ANONYMOUS wrote Depends on whether the function returns a value or not. You could just always have the function return a double and just add return 0.0 to the end of the function if there is no return value.


SVG not supported 8:17pm Wed 11th Sep, Joshua N.

ANONYMOUS wrote From your attachment your runml isn't correct. As many of the samples print, yet there is no output in your terminal.


SVG not supported 8:16pm Wed 11th Sep, Joshua N.

ANONYMOUS wrote If the ml file prints then the correct output should appear in the terminal. The ml file should throw an error if there a syntax error in the ml file. Likewise the ml file should correctly run and not throw an error if there are no er...


SVG not supported 8:12pm Wed 11th Sep, Joshua N.

Hi Anon, Amitava said the deadline is next week Friday.


 UWA week 36 (2nd semester, mid-semester break) ↓
SVG not supported 5:27pm Fri 6th Sep, Joshua N.

You can do that if you want but I think the easiest way is to replace a with 0.0 if it doesn't match any identifier stored.


SVG not supported 5:25pm Fri 6th Sep, Joshua N.

Hi Zexu, "7.variables do not need to be defined before being used in an expression, and are automatically initialised to the (real) value 0.0" "12. a function's parameters and any other identifiers used in a function body are local to that function, an...


SVG not supported 4:56pm Fri 6th Sep, Joshua N.

Hi From my understanding, Chris said "appearing" so, you should only see at most 50 unique identifiers in a single ml file. So, in the case above b would count towards the total.


SVG not supported 4:56pm Fri 6th Sep, Joshua N.

ANONYMOUS wrote Hi From my understanding, Chris said "appearing" so, you should only see at most 50 unique identifiers in a single ml file. So, in the case above b would count towards the total.


SVG not supported 4:50pm Fri 6th Sep, Joshua N.

Actually sorry, I just realized made a mistake the datatype used should be doubles not floats because it has more precision (e.g. reduces rounding errors). So that way if you're multiplying dividing real numbers and showing 6 decimal plac...


SVG not supported 4:45pm Fri 6th Sep, Joshua N.

ANONYMOUS wrote "4.only a single datatype is supported - real numbers, such as 2.71828" All parameters will be real numbers (doubles) as that is the only datatype supported.


SVG not supported 2:24pm Fri 6th Sep, Joshua N.

functions


SVG not supported 2:24pm Fri 6th Sep, Joshua N.

ANONYMOUS wrote Hi, There can be zero or more function in ml.


SVG not supported 9:22pm Thu 5th Sep, Joshua N.

ANONYMOUS wrote Hi question is answered here https secure.csse.uwa.edu.au run help2002?p np opt U145


SVG not supported 7:06pm Thu 5th Sep, Joshua N.

np. It is this bit "Otherwise, whitespace can (but doesn't need to) appear anywhere else" In other words, both ways of calling the function as you have shown above are correct. A function call can have white space but doesn't need to have white sp...


SVG not supported 5:20pm Thu 5th Sep, Joshua N.

ANONYMOUS wrote I feel you are reading too deeply into that section of that paragraph. If you continue reading "The strategy is to first translate programs written in other languages, such as our ml, to C, to compile that translated C code using a st...


SVG not supported 4:29pm Thu 5th Sep, Joshua N.

Hi Harrison Sorry for the delay, unfortunately, there's been sudden changes to the teaching staff, so I have to wait for the new unit coordinator to clarify these questions. Answered here https secure.csse.uwa.edu.au run help2002?p np opt U201 perr...


SVG not supported 3:27pm Thu 5th Sep, Joshua N.

ANONYMOUS wrote Honestly it would be very hard to tell if a statement is meant to be in a function but it isn't. Since ml syntax allows statements to be inside or outside a function, there's no way of telling if they belong to a function if they aren...


SVG not supported 12:10pm Thu 5th Sep, Joshua N.

There are no integers in the ml program, all the constants are real numbers, as that is the only datatype supported by ml. So, all the constant integer values in the ml program are actually floats. e.g. "2" is technically "2.0". If there are rounding...


SVG not supported 7:59am Thu 5th Sep, Joshua N.

ANONYMOUS wrote There are no guarantees what the last statement in a function will be, it could return, it could print, or it could be another statement (the syntax of ml allows this). So, relying on seeing a particular statement to know if the funct...


SVG not supported 7:48am Thu 5th Sep, Joshua N.

ANONYMOUS wrote You do not need to display the comments in the c file. Since the c file gets deleted anyway. So, when you come across a comment in ml you can just ignore it.


SVG not supported 10:08pm Wed 4th Sep, Joshua N.

Ok let me try writing this out again, since half of my response got deleted. When you run your program like so . runml sample.ml runml (your project) will read the ml file given as the first parameter (in this case sample.ml), it will validate th...


SVG not supported 10:04pm Wed 4th Sep, Joshua N.

For some reason it isn't appearing. The code is ". runml sample.ml"


SVG not supported 10:04pm Wed 4th Sep, Joshua N.

The content in the code block is . runml sample.ml


SVG not supported 10:03pm Wed 4th Sep, Joshua N.

ANONYMOUS wrote Hi anon, I'm not 100 sure what you are asking but when you run your program like so . runml sample.ml runml (your project) will read the ml file given as the first parameter (in this case sample.ml), it will validate the m...


SVG not supported 7:36pm Wed 4th Sep, Joshua N.

Hi Both of those messages are fine, but in general the more descriptive the error message, the better.


SVG not supported 7:28pm Wed 4th Sep, Joshua N.

Hi Josiah, The ml language only supports real numbers. So, an ml file wouldn't contain a string literal.


SVG not supported 7:25pm Wed 4th Sep, Joshua N.

Hi Chenjun, When printed, numbers that are exact integers must be printed without any decimal places; other numbers must be printed with exactly 6 decimal places. Your program wouldn't need two datatypes, it would just need to change the format string ...


SVG not supported 7:21pm Wed 4th Sep, Joshua N.

Hello anon, Judging by the Syntax of ml, I would say parenthesis are required for function calls.


SVG not supported 7:14pm Wed 4th Sep, Joshua N.

ANONYMOUS wrote Hi anon, I believe your question in answered in these two posts https secure.csse.uwa.edu.au run help2002?p np opt U145 https secure.csse.uwa.edu.au run help2002?opt U132


SVG not supported 7:12pm Wed 4th Sep, Joshua N.

Yes, that would break my cool idea. However, we can still fix it, just keep track of the quotes too. If we saw a quote ignore everything until we see another quote. Unfortunately, ml only supports real numbers, which makes me sad as this circumstance ...


SVG not supported 8:34am Wed 4th Sep, Joshua N.

Hi Guys, Sorry about the delays replying. Some questions about project requirements are really good so I need further clarification (from teaching staff) before I can respond (I don't want to make the project too hard). So, for now if you are unsure o...


SVG not supported 8:10am Wed 4th Sep, Joshua N.

I should also mention you'd likely need to recursively "check" functions, e.g. If you're checking the parameters and encounter another function, start checking the new function. But like I said I'm not sure if it is necessary.


SVG not supported 8:02am Wed 4th Sep, Joshua N.

I'm not sure if it is necessary but it does sound like fun (if you're me anyway). You could check the number of arguments by counting the number of commas and the number of open brackets without a closing bracket. If number of open brackets is 1, then...


SVG not supported 9:41pm Mon 2nd Sep, Joshua N.

Hey Anon your question is answered here https secure.csse.uwa.edu.au run help2002?p np opt U172


SVG not supported 9:29pm Mon 2nd Sep, Joshua N.

Hi Functions don't always have a return statement (see sample05.ml). Your other question in this post https secure.csse.uwa.edu.au run help2002?p np opt U145


SVG not supported 9:21pm Mon 2nd Sep, Joshua N.

Hello, I think your question is answered by this post https secure.csse.uwa.edu.au run help2002?p np opt U145


SVG not supported 9:19pm Mon 2nd Sep, Joshua N.

Hey Guys, sadly I am not the prof, but I believe your questions are answered by the following posts 1. https secure.csse.uwa.edu.au run help2002?p np opt U145 2.https secure.csse.uwa.edu.au run help2002?opt U132


SVG not supported 1:58pm Mon 2nd Sep, Joshua N.

Hi, your question is answered here https secure.csse.uwa.edu.au run help2002?p np opt U145


SVG not supported 1:54pm Mon 2nd Sep, Joshua N.

Hi, your question is answered here https secure.csse.uwa.edu.au run help2002?p np opt U151


 UWA week 35 (2nd semester, week 6) ↓
SVG not supported 8:39pm Fri 30th Aug, Joshua N.

Hi, the way I remember it is that refers to a pointer if a datatype comes before it e.g. int . If there is no type beforehand, then is the dereference operation. e.g. int p , declares a pointer to an int. p refers to...


SVG not supported 9:17pm Tue 27th Aug, Joshua N.

This forum post may answer your question https secure.csse.uwa.edu.au run help2002?p np opt U143


SVG not supported 9:13pm Tue 27th Aug, Joshua N.

Hi unfortunately I am not Chris, but this forum post may answer your question post (https secure.csse.uwa.edu.au run help2002?p np opt U151)


 UWA week 33 (2nd semester, week 4) ↓
SVG not supported 5:10pm Wed 14th Aug, Joshua N.

ANONYMOUS wrote You're right. I think there is a typo in the answer. None of the options are correct. However, there is one option that is very close to the correct answer. Can you see which one it is?


SVG not supported 4:59pm Wed 14th Aug, Joshua N.

ANONYMOUS wrote One place to the left means index - 1 . e.g. If an integer is at index 3 it will be at index 2 after the code runs. Likewise, if an integer is at index 1, then after the code runs it will be at index 0. I hope that makes sense.


 UWA week 32 (2nd semester, week 3) ↓
SVG not supported 7:38am Fri 9th Aug, Joshua N.

Hi Guys, I am just reminding you to always keep up to date with the lectures, workshops and labs . If you don't you will struggle with this unit as there is a lot of content. Do not skip the lab exercises they are assessable and build up the fou...


 UWA week 30 (2nd semester, week 1) ↓
SVG not supported 9:17pm Thu 25th Jul, Joshua N.

Hey Jinyoung If I remember correctly floats are 4 bytes and doubles are 8 bytes (hence the name double) but Chris may need to clarify. An integer value must be at least 2 bytes (or 16 bits) but it is usually 4 bytes (32 bits). It's a bit confusing ...

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy