Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
6199a722
Commit
6199a722
authored
13 years ago
by
Ali Sinan Köksal
Browse files
Options
Downloads
Patches
Plain Diff
calendar example with Scala 2.9
parent
9740e961
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cp-demo/executing-specs/Calendar.scala
+11
-12
11 additions, 12 deletions
cp-demo/executing-specs/Calendar.scala
with
11 additions
and
12 deletions
cp-demo/executing-specs/Calendar.scala
+
11
−
12
View file @
6199a722
import
cp.Definitions._
import
cp.Definitions._
import
cp.Terms._
import
cp.Terms._
object
Calendar
extends
App
lication
{
object
Calendar
extends
App
{
/* maybe more readable with leapDaysUntil's
final
val
totalDays
=
10593
final
val
originYear
=
1980
val
(
year
,
day
)
=
((
year
:
Int
,
day
:
Int
)
=>
totalDays
==
(
year
-
originYear
)
*
365
+
(
year
-
1
)
/
4
-
(
year
-
1
)
/
100
+
(
year
-
1
)
/
400
-
((
originYear
-
1
)
/
4
-
(
originYear
-
1
)
/
100
+
(
originYear
-
1
)
/
400
)
+
day
&&
day
>
0
&&
day
<=
366
).
solve
println
(
"Year : %d, day : %d"
format
(
year
,
day
))
/* alternate version with intermediate "leapDaysUntil" variables
def yearAndDay(totalDays : Int, originYear : Int) : (Int, Int) = {
def yearAndDay(totalDays : Int, originYear : Int) : (Int, Int) = {
val (y, d, _, _) = ((year : Int, day : Int, lduYear : Int, lduOrigin : Int) => totalDays == (year - originYear) * 365 + lduYear - lduOrigin + day &&
val (y, d, _, _) = ((year : Int, day : Int, lduYear : Int, lduOrigin : Int) => totalDays == (year - originYear) * 365 + lduYear - lduOrigin + day &&
...
@@ -13,17 +22,7 @@ object Calendar extends Application {
...
@@ -13,17 +22,7 @@ object Calendar extends Application {
(y, d)
(y, d)
}
}
println(yearAndDay(10593, 1980))
*/
*/
final
val
totalDays
=
10593
final
val
originYear
=
1980
val
(
year
,
day
)
=
((
year
:
Int
,
day
:
Int
)
=>
totalDays
==
(
year
-
originYear
)
*
365
+
(
year
-
1
)
/
4
-
(
year
-
1
)
/
100
+
(
year
-
1
)
/
400
-
((
originYear
-
1
)
/
4
-
(
originYear
-
1
)
/
100
+
(
originYear
-
1
)
/
400
)
+
day
&&
day
>
0
&&
day
<=
366
).
solve
println
(
"Year : %d, day : %d"
format
(
year
,
day
))
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment