On Fri, Apr 21, 2017 at 12:43 AM Ian Davis wrote:
>
>
>
> On Fri, 21 Apr 2017, at 03:31 AM, Ivan Kurnosov wrote:
>
> @Rob,
>
> honestly to me they look the same:
>
>
> func IsSorted(data Interface) bool {
> n := data.Len()
> for i := n - 1; i > 0; i-- {
> if data.Less(i, i-1) {
>
Some compilers know that and create a hidden variable (B and C on GCOS, if
memory serves)
On Thursday, April 20, 2017 at 11:50:39 PM UTC-4, andrey mirtchovski wrote:
>
> > 297 for i := n - 1; i > 0; i-- {
>
> "i > 0" is cheaper than "i < n" on some processors :)
>
>
--
You received this mess
On Fri, 21 Apr 2017, at 03:31 AM, Ivan Kurnosov wrote:
> @Rob,
>
> honestly to me they look the same:
>
>
> func IsSorted(data Interface) bool {
> n := data.Len() for i := n - 1; i > ; i-- { if data.Less(i, i-1) {
>return false } } return true }
>
>
> func IsSortedForward(data sor
Speaking low level - how about memory prefetch algorithms (os, hardware)?
Do they work equally good when one iterates backward?
On Friday, April 21, 2017 at 3:50:39 PM UTC+12, andrey mirtchovski wrote:
>
> > 297 for i := n - 1; i > 0; i-- {
>
> "i > 0" is cheaper than "i < n" on some processors
> 297 for i := n - 1; i > 0; i-- {
"i > 0" is cheaper than "i < n" on some processors :)
On Thu, Apr 20, 2017 at 3:14 AM, wrote:
> Hi
>
> At the moment it is implemented as
>
>295func IsSorted(data Interface) bool {
>296n := data.Len()
>297fo
@Rob,
honestly to me they look the same:
func IsSorted(data Interface) bool {
n := data.Len()
for i := n - 1; i > 0; i-- {
if data.Less(i, i-1) {
return false
}
}
return true
}
func IsSortedForward(data sort.Interface) bool {
n := data.Len()
f
Try it the other way. You'll see it's not so clean.
-rob
On Thu, Apr 20, 2017 at 7:47 PM, Ian Lance Taylor wrote:
> On Thu, Apr 20, 2017 at 2:14 AM, wrote:
> >
> > At the moment it is implemented as
> >
> >295 func IsSorted(data Interface) bool {
> >296 n := data.Len()
> >297 for
On Thu, Apr 20, 2017 at 2:14 AM, wrote:
>
> At the moment it is implemented as
>
>295 func IsSorted(data Interface) bool {
>296 n := data.Len()
>297 for i := n - 1; i > 0; i-- {
>298 if data.Less(i, i-1) {
>299 return false
>300 }
>301 }
>302 return true
>303 }
Hi
At the moment it is implemented as
295 func IsSorted(data Interface) bool { 296 n := data.Len()
297 for i := n - 1; i > 0; i-- { 298 if
data.Less(i, i-1) { 299return false 300
} 301