Skip to main content
added 11 characters in body
Source Link
user61980
user61980

It seems to me that for Mathematica (and potentially other languages), the function/program distinction for any given code isn't intrinsic to the code, but depends on how you use the code to satisfy a question's spec. If evaluating code on its own gives the correct output (asking the user for input if appropriate), then we call it a full program solution (code could be used as the head of an expression, but it most likely wouldn't satisfy the spec). Likewise, if you must evaluate code[x, y, ...] where x, y, ..., are the input in order to get the correct output, then we call it a function solution (you could evaluate code on its own without using it as the head of an expression, but it most likely wouldn't satisfy the spec).

I would say that $SystemWordLength is a perfectly valid full program solution to Is my OS 32-bit or 64-bit?. It's not a snippet since it doesn't expect input to be hardcoded into some variable. Note that it doesn't matter whether we consider it as Mathematica REPL code or a .wl file run from the command line. In the former case, the evaluated expression is printed implicitly, and in the latter, programs are allowed to output using their return value.

It seems to me that for Mathematica (and potentially other languages), the function/program distinction for any given code isn't intrinsic to the code, but depends on how you use the code to satisfy a question's spec. If evaluating code gives the correct output (asking the user for input if appropriate), then we call it a full program solution (code could be used as the head of an expression, but it most likely wouldn't satisfy the spec). Likewise, if you must evaluate code[x, y, ...] where x, y, ..., are the input in order to get the correct output, then we call it a function solution (you could evaluate code on its own without using it as the head of an expression, but it most likely wouldn't satisfy the spec).

I would say that $SystemWordLength is a perfectly valid full program solution to Is my OS 32-bit or 64-bit?. It's not a snippet since it doesn't expect input to be hardcoded into some variable. Note that it doesn't matter whether we consider it as Mathematica REPL code or a .wl file run from the command line. In the former case, the evaluated expression is printed implicitly, and in the latter, programs are allowed to output using their return value.

It seems to me that for Mathematica (and potentially other languages), the function/program distinction for any given code isn't intrinsic to the code, but depends on how you use the code to satisfy a question's spec. If evaluating code on its own gives the correct output (asking the user for input if appropriate), then we call it a full program solution (code could be used as the head of an expression, but it most likely wouldn't satisfy the spec). Likewise, if you must evaluate code[x, y, ...] where x, y, ..., are the input in order to get the correct output, then we call it a function solution (you could evaluate code on its own without using it as the head of an expression, but it most likely wouldn't satisfy the spec).

I would say that $SystemWordLength is a perfectly valid full program solution to Is my OS 32-bit or 64-bit?. It's not a snippet since it doesn't expect input to be hardcoded into some variable. Note that it doesn't matter whether we consider it as Mathematica REPL code or a .wl file run from the command line. In the former case, the evaluated expression is printed implicitly, and in the latter, programs are allowed to output using their return value.

Source Link
user61980
user61980

It seems to me that for Mathematica (and potentially other languages), the function/program distinction for any given code isn't intrinsic to the code, but depends on how you use the code to satisfy a question's spec. If evaluating code gives the correct output (asking the user for input if appropriate), then we call it a full program solution (code could be used as the head of an expression, but it most likely wouldn't satisfy the spec). Likewise, if you must evaluate code[x, y, ...] where x, y, ..., are the input in order to get the correct output, then we call it a function solution (you could evaluate code on its own without using it as the head of an expression, but it most likely wouldn't satisfy the spec).

I would say that $SystemWordLength is a perfectly valid full program solution to Is my OS 32-bit or 64-bit?. It's not a snippet since it doesn't expect input to be hardcoded into some variable. Note that it doesn't matter whether we consider it as Mathematica REPL code or a .wl file run from the command line. In the former case, the evaluated expression is printed implicitly, and in the latter, programs are allowed to output using their return value.