Heads-I-Lose

Check-in [76eac348fc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Bug fix - nth_wrap didn't work for last items in a list

I only noticed this just recently, which means it has been wrong for
about a year! I think it's just luck I'd never come across an issue with
it not working.

I don't know if I'd got half way through writing this and forgot to
finish it off, or whether I was just being an imbecile: If the remainder
is 0 then that should return the last item in a list, not just the
number 1.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | v1.1.0
Files: files | file ages | folders
SHA3-256: 76eac348fca2657b9258d798906358a28e27971f66580932eafc3690a8587b34
User & Date: base@atomicules.co.uk 2014-11-29 17:34:34
Context
2014-11-29
17:42
Merge branch 'master' into osrm

Noticed the nth_wrap problem whilst developing this osrm branch as
building the list of winds would be incomplete. check-in: 915a1fb3d0 user: base@atomicules.co.uk tags: origin/master, trunk

17:34
Bug fix - nth_wrap didn't work for last items in a list

I only noticed this just recently, which means it has been wrong for
about a year! I think it's just luck I'd never come across an issue with
it not working.

I don't know if I'd got half way through writing this and forgot to
finish it off, or whether I was just being an imbecile: If the remainder
is 0 then that should return the last item in a list, not just the
number 1. Leaf check-in: 76eac348fc user: base@atomicules.co.uk tags: trunk, v1.1.0

2014-03-11
14:43
Merge branch 'master' of github.com:atomicules/heads-I-lose check-in: 736cabe83d user: base@atomicules.co.uk tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to headsilose.erl.

108
109
110
111
112
113
114
115


116
117
118
119
120
121
122


nth_wrap(N, List) ->
	Rem = N rem (length(List)),
	if Rem > 0 ->
		lists:nth(Rem, List);
	Rem =:= 0 ->
		1


	end.


find_next_day(Date_today) ->
	%get in seconds
	Seconds_today = calendar:datetime_to_gregorian_seconds(Date_today),
	Date_tomorrow = calendar:gregorian_seconds_to_datetime(Seconds_today+86400),







<
>
>







108
109
110
111
112
113
114

115
116
117
118
119
120
121
122
123


nth_wrap(N, List) ->
	Rem = N rem (length(List)),
	if Rem > 0 ->
		lists:nth(Rem, List);
	Rem =:= 0 ->

		%Get last of list
		hd(lists:reverse(List))
	end.


find_next_day(Date_today) ->
	%get in seconds
	Seconds_today = calendar:datetime_to_gregorian_seconds(Date_today),
	Date_tomorrow = calendar:gregorian_seconds_to_datetime(Seconds_today+86400),