ANONYMOUS wrote:
> Hi, would the following code as a .ml file be syntactically valid?
>
> Additionally, can comments be indented with a '/t' outside of a function or will this cause an error? Chris has said randomly indented lines outside of a function is not permitted, but I am not sure if this applies to comments as well.
>
> This file also assumes that whitespace anywhere except at the start of the line is valid (therefore any line starting with a whitespace (even if it is a commented out line with just #), including any lines with whitespace before or after a '\t' character within a function, causes an error).
> Could I please get a clear cut yes or no whether or not this is true instead of a link to another help forum post, I have read all of the posts regarding whitespaces and still am not certain if this is correct. The post that is always linked says 'Whitespace can only appear at the beginning of a line if it is a tab under a function definition' is true, but whitespace and tab are not the same thing so it is confusing.
>
>
> ```
> # this file should print the following (only the numbers):
> # 9
> # 16
> # 0
> # 2
> # 2.500000
> # 3
> # 1
> #
> #
> #
> # additional whitespace except at the start of a line is valid (? still waiting on clarification ?)
> # 9 is printed
> one <- 1
> #
> function increment value
> return value + one
> #
> print increment( 3 ) + increment ( 4 )
> #
> #
> #
> # from
[help2002]⬈
> # functions can call another function as a parameter
> # 16 is printed
> function printsum a b
> print a + b
> print printsum(increment( 5 ) , 10)
> #
> #
> #
> # variables do not need to be defined before being used in an expression, and are automatically initialised to the (real) value 0.0
> print d
> #
> #
> #
> $ from
[help2002]⬈
> # functions do not need to end with a return or print statement, if there is no tab the function has ended
> # variable reassignment is allowed
> # 2 is printed
> function none
> one -> 2
> none( )
> print one
> #
> #
> #
> # comments can start in the middle of a line
> # 2.500000 is printed
> print 2.5 # comment
> #
> #
> #
> # from
[help2002]⬈
> # 3 is printed then 1 is printed, since noreturn(1, 2) would return 0
> function noreturn x y
> print x + y
> print 1 + noreturn(1, 2)
> ```
You should make simplifying assumptions, and clearly write those assumptions in your report. I am not sure whether a report was required in the original project description, but you can submit a report that lists all the assumptions you have made.