-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweather.exs
31 lines (25 loc) · 894 Bytes
/
weather.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
defmodule WeatherHistory do
def for_location_27([]), do: []
def for_location_27([ [time, 27, temp, rain] | tail]), do: [ [time, 27, temp, rain] | for_location_27(tail)]
def for_location_27([_|tail]), do: for_location_27(tail)
#Generic location
def for_location([],_target_loc), do: []
def for_location([ head=[_, target_loc, _, _] | tail], target_loc) do
[head | for_location(tail, target_loc)]
end
def for_location([_|tail], target_loc), do: for_location(tail,target_loc)
def test_data do
[
[1366225622, 26, 15, 0.125],
[1366225622, 27, 15, 0.45],
[1366225622, 28, 21, 0.25],
[1366229222, 26, 19, 0.081],
[1366229222, 27, 17, 0.468],
[1366229222, 28, 15, 0.60],
[1366232822, 26, 22, 0.095],
[1366232822, 27, 21, 0.05],
[1366232822, 28, 24, 0.03],
[1366236422, 26, 17, 0.025]
]
end
end