mirror of https://git.sr.ht/~garritfra/sabre
Garrit Franke
3 years ago
14 changed files with 238 additions and 10 deletions
@ -0,0 +1,17 @@ |
|||||||
|
// There are no nested expressions yet, so we have to hack a little bit |
||||||
|
|
||||||
|
fn main() { |
||||||
|
let year = 2020 |
||||||
|
|
||||||
|
let divisibleBy4 = year % 4 == 0 |
||||||
|
let divisibleBy100 = year % 100 != 0 |
||||||
|
let divisibleBy400 = year % 400 == 0 |
||||||
|
|
||||||
|
let ly = divisibleBy4 && divisibleBy100 |
||||||
|
|
||||||
|
if ly || divisibleBy400 { |
||||||
|
return "Leap year" |
||||||
|
} else { |
||||||
|
return "Not a leap year" |
||||||
|
} |
||||||
|
} |
@ -1,10 +1,17 @@ |
|||||||
|
// There are no nested expressions yet, so we have to hack a little bit |
||||||
|
|
||||||
fn main() { |
fn main() { |
||||||
let num = 5 |
let year = 2020 |
||||||
if num > 5 { |
|
||||||
return num |
let divisibleBy4 = year % 4 == 0 |
||||||
} else if num < 5 { |
let divisibleBy100 = year % 100 != 0 |
||||||
return 1 |
let divisibleBy400 = year % 400 == 0 |
||||||
|
|
||||||
|
let ly = divisibleBy4 && divisibleBy100 |
||||||
|
|
||||||
|
if ly || divisibleBy400 { |
||||||
|
return "Leap year" |
||||||
} else { |
} else { |
||||||
return num + 1 |
return "Not a leap year" |
||||||
} |
} |
||||||
} |
} |
@ -1 +1,16 @@ |
|||||||
|
/**
|
||||||
|
* Copyright 2020 Garrit Franke |
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
pub mod string_util; |
pub mod string_util; |
||||||
|
Loading…
Reference in new issue