• (nodebb)

    Yeah! Frist!

    Let's catch all da frist exceptions!

  • Malte (unregistered) in reply to ESkIiHccraVBD

    Good old Pokemon exception handling.

  • (nodebb)

    I've had to write some Matlab code recently, and yeah.

    Matlab has a few neat features. Many functions can operate on a scalar or array, and if you give it an array it will automagically apply the function to every element of the array. This feature would be a lot better if Matlab handled type annotations correctly, so that someone reading the code could see what the hell the code is doing or which of the hundred different slightly-incompatible kinds of arrays it's working with.

  • (nodebb)

    They aren't set to zero, they are set to not exist, and down the line something is supposed to barf with "No variable in scope". Which is a different kind of headache to debug.

  • (nodebb) in reply to Dragnslcr

    if you give it an array it will automagically apply the function to every element of the array.

    Isn't this what LISP's map family of functions, and Python list comprehensions, do?

  • RLB (unregistered)

    Also, why does the catch clause set bigStruct to something... random?, but leave FileName and PathName alone, while the try clause does the opposite?

  • (nodebb)

    Just for the record, I am NOT that Carl W.

  • (nodebb)

    MATLAB: where the initiating seed for random() is by default set to the same value at the start of every session. Where functions will accept 1 xN vectors but not Nx1 vectors
    Where the default for the "clear" aka rm or del, is >> clear all . Just what you'd want.

  • (nodebb) in reply to cellocgw

    MATLAB: where the initiating seed for random() is by default set to the same value at the start of every session.

    I don't see the problem, you need it to act that way so that it can be tested repeatedly.

    /s

  • Tetragramm (unregistered) in reply to RLB

    In Matlab, struct is your empty constructor. So it's not random, just empty.

    That doesn't answer "why", but...

  • (nodebb)

    Matlab is arcane because it's designed to work on matrices. You'd represent a vector as a matrix and then apply transformations to it via other matrices and mixing code and data gets very messy very quickly. (I was a whiz at it at the time and could autogenerate my entire homework from a Matlab script with all the graphs and such).

    Though I used an ancient version they had students use. I think modern versions include a compiler to C and other stuff

  • (nodebb) in reply to Tetragramm

    In Matlab, struct is your empty constructor. So it's not random, just empty.

    Just to clarify a bit, struct there calls the function named struct, even though it doesn't have parentheses (i.e. struct()) like most other languages require.

  • (nodebb) in reply to The Beast in Black

    Isn't this what LISP's map family of functions, and Python list comprehensions, do?

    Yes, but in Matlab you don't have to use a map function or anything similar (assuming you have one of the kinds of arrays where it works; see my earlier comment). You can just have something like floor(array_of_floats) instead of map(floor, array_of_floats).

  • (nodebb) in reply to cellocgw

    functions will accept 1 xN vectors but not Nx1 vectors

    That's not a WTF. 1 x n and n x 1 are absolutely not the same thing.

  • (nodebb)

    Or more explictly, NxM and MxN matrices are completely different things. Just like multiplying two matrices is not commutative (AB is not the same as BA, and it's even possible that B*A cannot be performed).

    There are various transforms you can apply to permute a 1xN to an Nx1 matrix or NxM to MxN.

Leave a comment on “Cancel Catch”

Log In or post as a guest

Replying to comment #696729:

« Return to Article