Re: [julia-users] Julian way to write longer if/elseif/else clauses?

2014-05-02 Thread Cameron McBride
Excellent. Thanks to both of you!

Cameron


On Fri, May 2, 2014 at 11:11 AM, Kevin Squire wrote:

>
>
> On Friday, May 2, 2014, Cameron McBride  wrote:
>
>> I'm still trying to settle into proper syntax and style, and all comments
>> are welcome!
>>
>> For potentially longer if / elseif / else clauses, e.g.
>>
>> # an overly simplistic example
>> if ndims(wt) == 2
>>println("Matrix stuff")
>> elseif ndims(wt) == 1
>>println("Vector stuff")
>> else
>>println("Scalar stuff")
>> end
>>
>> Multiple dispatch doesn't seem to help the specific case I have in mind,
>> as this is only a small part of the logic.
>>
>> This is perhaps as easy application of a case / switch statement, which I
>> don't think Julia has (I have ruby's case / when / else in mind).
>>
>> Even more general, is there any mechanism to do pattern matching (e.g.
>> 'match' in OCaml)?
>>
>
> Match.jl does pattern matching.
>
>  Cheers,
>   Kevin
>


Re: [julia-users] Julian way to write longer if/elseif/else clauses?

2014-05-02 Thread Kevin Squire
On Friday, May 2, 2014, Cameron McBride  wrote:

> I'm still trying to settle into proper syntax and style, and all comments
> are welcome!
>
> For potentially longer if / elseif / else clauses, e.g.
>
> # an overly simplistic example
> if ndims(wt) == 2
>println("Matrix stuff")
> elseif ndims(wt) == 1
>println("Vector stuff")
> else
>println("Scalar stuff")
> end
>
> Multiple dispatch doesn't seem to help the specific case I have in mind,
> as this is only a small part of the logic.
>
> This is perhaps as easy application of a case / switch statement, which I
> don't think Julia has (I have ruby's case / when / else in mind).
>
> Even more general, is there any mechanism to do pattern matching (e.g.
> 'match' in OCaml)?
>

Match.jl does pattern matching.

Cheers,
  Kevin


[julia-users] Julian way to write longer if/elseif/else clauses?

2014-05-02 Thread Cameron McBride
I'm still trying to settle into proper syntax and style, and all comments
are welcome!

For potentially longer if / elseif / else clauses, e.g.

# an overly simplistic example
if ndims(wt) == 2
   println("Matrix stuff")
elseif ndims(wt) == 1
   println("Vector stuff")
else
   println("Scalar stuff")
end

Multiple dispatch doesn't seem to help the specific case I have in mind, as
this is only a small part of the logic.

This is perhaps as easy application of a case / switch statement, which I
don't think Julia has (I have ruby's case / when / else in mind).

Even more general, is there any mechanism to do pattern matching (e.g.
'match' in OCaml)?

Cameron