Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.29 KB | None | 0 0
  1. import std.stdio;
  2.  
  3. void main()
  4. {
  5.     pure bool leapYear(uint y)
  6.     {
  7.         auto result = (y % 4) == 0 && (y % 100 || (y % 400) == 0);
  8.         if (result) writeln(y, " is a leap year!"); // Error!
  9.         // Cannot call impure function writeln from pure function!
  10.         return result;
  11.     }
  12.    
  13.     leapYear(1);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement