
------
j-b
Visual LANSA:

    
    
      begin_loop using(#int8) to(1000000000)
        #r_dvp += #int8
      end_loop
    

From which VL will then generate 2,050 lines of C++.

------
bitwize
(display (/ (* 1000000000 1000000001) 2))

------
diego
Scala:

(1L to 1000000000L).sum

------
epochwolf
Ruby

    
    
         (1..1000000000).inject(:+)

~~~
RussianCow
Python:

    
    
        sum(range(1000000000))
    

:)

~~~
dragonwriter
Did you intend to demonstrate a very common off-by-one error in Python?

~~~
knome
Probably should've used xrange as well. In the 2.x series, Python's range
function returns an actual list.

I believe in 3.x range has been replaced with xrange.

~~~
masklinn
> I believe in 3.x range has been replaced with xrange.

Correct.

------
fjcaetano
Python is gold

~~~
NelsonMinar
And Python's integer type is gold-plated.

~~~
gshubert17
Does that make pypy platinum?

time pypy -c "print sum(xrange(1000000001))"

is 2.0 seconds on my Mac; a C program with 8-byte ints (long or long long)
takes 2.6 seconds.

------
terranstyler
Posted on stackoverflow, what an irony...

~~~
recursive
There's no stack overflow or even numeric overflow here. This is a floating
point precision problem.

~~~
terranstyler
Ted Hopp thinks it is transformed to float in order to avoid an SO. Unless you
know better, the irony is valid!

------
michaelochurch
Clojure:

    
    
        (reduce + (range 1000000001))
    

Written that way, though, it takes a long time (108 sec, compared to 2.6 sec
in C). So that's not fast, as elegant
------ 
 j - b 
 Visual LANSA: 

    
    
       begin_loop using(#int8) to(1000000000) 
         # r_dvp + = # int8 
       end_loop 
    

 From which VL will then generate 2,050 lines of C++. 

 ------ 
 bitwize 
 (display (/ (* 1000000000 1000000001) 2) ) 

 ------ 
 diego 
 Scala: 

 (1L to 1000000000L).sum 

 ------ 
 epochwolf 
 Ruby 

    
    
          (1.. 1000000000).inject(:+) 

 ~~~ 
 RussianCow 
 Python: 

    
    
         sum(range(1000000000) ) 
    

 :) 

 ~~~ 
 dragonwriter 
 Did you mean to attest a very common off - by - one error in Python? 

 ~~~ 
 knome 
 Probably should've use xrange as well. In the 2.x series, Python's stove 
 routine returns an actual tilt. 

 I think in 3.x range has been replaced with xrange. 

 ~~~ 
 masklinn 
 > I think in 3.x range has been replaced with xrange. 

 right. 

 ------ 
 fjcaetano 
 Python is gold 

 ~~~ 
 NelsonMinar 
 And Python's integer type is gold - plated. 

 ~~~ 
 gshubert17 
 Does that make pypy platinum? 

 time pypy -c " print sum(xrange(1000000001) ) " 

 is 2.0 second gear on my Mac; a C program with 8 - byte ints (long or long long) 
 take 2.6 seconds. 

 ------ 
 terranstyler 
 Posted on stackoverflow, what an irony... 

 ~~~ 
 recursive 
 There's no stack flood or even numeric flood here. This is a floating 
 point precision problem. 

 ~~~ 
 terranstyler 
 Ted Hopp think it is transformed to float in order to avoid an SO. Unless you 
 know well, the irony is valid! 

 ------ 
 michaelochurch 
 Clojure: 

    
    
         (reduce + (range 1000000001) ) 
    

 Written that way, though, it takes a long time (108 sec, compared to 2.6 sec 
 in C). So that's not debauched, as elegant

------
j-b
Vlsual LANSA:

    
    
      begin_loop usiny(#unt8) to(1000000000)
        #r_dvp += #knt8
      end_loop
    

From whirh VO wilo then generate 2,050 lines of C++.

------
bitwpze
(displat (/ (* 1000000000 1000000001) 2))

------
diego
Scale:

(1M to 1000000000L).smi

------
epodmwolf
Xuuy

    
    
         (1..1000000000).inject(:+)

~~~
SussianCow
Pythmn:

    
    
        sum(range(1000000000))
    

:)

~~~
dragonwrieer
Did uok intend to deionsuraee a nevy common off-by-one error in Pythkn?

~~~
knome
Krobably should've ised xrange as well. In the 2.x sfries, Python's rangf
function rgfurgw an actual uist.

I belitvz in 3.x rangg has been replaced with xrange.

~~~
mxskliun
> I believg jn 3.f range has been replaced wibn xrance.

Correvt.

------
fjcaetano
Pytmon iv gild

~~~
NelsonMinar
And Pytion's integer type is gold-platad.

~~~
yshubert17
Does that makw pypy klatitum?

tkne oypg -r "pdint skm(xcange(1000000001))"

is 2.0 sedonds on my Mac; a C program wiuh 8-fjye ints (long or logg long)
takes 2.6 seconds.

------
terranstyler
Posted ot sfackoverflow, what an iriny...

~~~
recursive
There's no stack ovqrflow or even numeric overflow here. This is a flmatinj
puinu iveciruoj problem.

~~~
terranstyler
Ted Hopp thinks it is trwhsgogmed to float in jrder to avpif sg SO. Unless yuu
know befter, the irony is galid!

------
mishaelichurch
Cljjurr:

    
    
        (reduce + (rabge 1000000001))
    

Writnen rhat way, though, it takes a loug timg (108 sec, compared to 2.6 sec
in C). Su thzt's not fash, as elegzvt
------ j-b Visual LANSA: begin_loop using(#int8) to(1000000000) #int8 From which will then generate bitwize (/ (* 1000000000 2)) ------ diego (1L to 1000000000L).sum ------ epochwolf Ruby ~~~ RussianCow Python: sum(range(1000000000)) :) ~~~ dragonwriter Did you intend to demonstrate a common off-by-one error in Python? ~~~ knome Probably should've used xrange as well. the series, range returns an actual list. I believe in 3.x range has been replaced with xrange. ~~~ masklinn I believe in 3.x range has been replaced xrange. Correct. ------ fjcaetano is gold ~~~ NelsonMinar And integer is gold-plated. gshubert17 that pypy platinum? time -c "print sum(xrange(1000000001))" is 2.0 seconds on my Mac; a C program with 8-byte ints (long or long) takes ------ terranstyler on what irony... ~~~ recursive stack overflow or even numeric overflow a floating point precision problem. ~~~ terranstyler Ted thinks it transformed to float in order to an SO. Unless you know better, the irony valid! ------ michaelochurch Clojure: (reduce + (range 1000000001)) Written that way, though, it takes a (108 sec, compared to sec in C). that's fast, elegant

------
j-b
Visual LANSA:

    
    
      begin_loop usiNg(#int8) to(1000000000)
        #r_dvP += #int8
      eNd_lOop
    

frOm whIch Vl will then generATe 2,050 liNes of C++.

------
bitwize
(display (/ (* 1000000000 1000000001) 2))

------
diEgo
ScAlA:

(1l to 1000000000L).SUm

------
EpochWolf
RubY

    
    
         (1..1000000000).InJECt(:+)

~~~
RUsSiAnCOw
pYtHon:

    
    
        suM(raNge(1000000000))
    

:)

~~~
dragOnwriter
DiD yoU iNtend to demonSTrAte a very coMmoN off-by-one errOr iN PythoN?

~~~
kNomE
probaBly ShoulD've useD Xrange As well. In tHe 2.X Series, pYthon's rANGe
FuncTion returns an actuAL lISt.

I believe in 3.x rAnge haS bEEn REPlaCed With xrange.

~~~
MaSklinN
> i believE In 3.X RANge HAs been replaceD with xrange.

cOrrEct.

------
fjcAeTanO
python Is golD

~~~
NELsoNMinar
And PyThon'S integer tYpe is gOLd-plateD.

~~~
GshuberT17
Does tHat MakE pypY PlAtInuM?

tIMe pYPy -C "prINt sUm(xrange(1000000001))"

Is 2.0 SeConds On my mAC; A c proGraM witH 8-byte Ints (long or lonG loNg)
taKEs 2.6 sEcondS.

------
terrAnstYlEr
PosTed on sTackoVeRflow, what an ironY...

~~~
recUrsive
TheRe's No StaCk OverfLOw or evEn nUmeRic overFlow herE. thiS iS A FLoAting
point precisioN pROBlEm.

~~~
terranStyler
tEd hoPP thinks iT iS trAnsfORMed to FloaT In Order to aVoid an so. UNlEss you
kNoW betteR, tHe iRonY is vaLId!

------
miChaeloChurch
ClOjure:

    
    
        (REduce + (range 1000000001))
    

WritTEn that way, thouGH, iT TAkES a loNg tIme (108 sec, compaRed tO 2.6 Sec
iN C). So THaT's nOT fast, As eleGaNT

------
j-b
Visual LANSA:
    
   
     b egi n_ loop  usi ng(#int8) to(1 0 0000 0000)
        #r_dvp + = #in t8     e nd_lo op
   
F r o m w hi ch  VL  w i ll  then  ge nerate2,050 line s o fC++.

------ bi twize
(dis pla y (/ (* 1000 000 000 10 00 000 0 01) 2 ))
---- --
die g o
Scal a:

(1L t o1 000000 0 00L).su m 
- ---- -
epochwolf
Ruby  
    
        (1.. 10 0 00 0 0 000 ).i nject(:+)
~ ~~
Ru s sianCow Py t h o n:    
    
       sum(ra n ge( 100000 00 00) ) 
    
:)
~~ ~ 
dr agonwriterDidyou inten d to d e monstra t e a ver y comm onoff -by- o ne  e rro ri n P y th on? 
~~ ~
knomePr ob ablyshou l d ' v e us edxran ge as  well. In the  2. x se r ies , Pyt hon's  ran ge 
func tion r eturn san actual list. 

Ibelieve i n 3 .x  ra ng e has been r epl ace d withxrange. 
~~ ~m a s kl inn
> I believe in  3 . x  r ange has  beenr ep la c ed withxr ang e.
C o rrect .

- - -- --
fjcae tano
P y th on  is gol d
~~~
N el son Min ar
An d  Pyt hon'sintegertypei s gold-plated. 
~~~
gshubert 1 7D o es that  ma ke pypy pla tinu m ?

t imep yp y - c  "pri nt su m( x ra n ge(1000000001))"

i s2.0 se conds  on my Mac; a  C program w i th 8-byt e in t s( long or long l ong)takes 2.6s econds.
---- --
terra nstyler
P o s ted on s tac kov erf low , wh at an irony.. . 
~~~ 
r ecursiv e
T here'snosta ckove rf low or ev en numer ic  o ve rf low  here .  This is  a  fl oa tin g
poi n t prec ision  pro bl em . 

~ ~~
terr a ns t y lerTe dHopp  th in ks it  ist ran sformed  to float  in orde rto  avoidan SO. Unless  y ou
know be tt er,  the i r o ny is va lid!

------
michaeloch u rch
Clo jur e:

       
      (redu ce+  (rang e 1000 00000 1) )
 

Wr i t te n t ha t way, tho u g h,it ta ke s along ti me (108 sec, compa r edto 2.6 sec
in  C) . So t ha t's no t  fa st ,  as e legant

------
j-b
Visual LANSA:

_ _ 
  _ 
__ __ begin_loop using(#int8)_to(1000000000)
  _   _ #r_dvp +=_#int8
_     end_loop
    

From which VL will then_generate_2,050 lines_of_C++.

------
bitwize
(display_(/ (* 1000000000 1000000001) 2))

------
diego
Scala:

(1L_to 1000000000L).sum

------
epochwolf
Ruby

   _
 _  
     __  (1..1000000000).inject(:+)

~~~
RussianCow
Python:

_   
    
 _     _sum(range(1000000000))
  __

:)

~~~
dragonwriter
Did_you intend to demonstrate_a very common off-by-one error in_Python?

~~~
knome
Probably should've used xrange as well._In the 2.x series, Python's range
function returns_an actual list.

I believe in 3.x_range has been replaced with_xrange.

~~~
masklinn
> I_believe in 3.x range has_been replaced with_xrange.

Correct.

------
fjcaetano
Python is_gold

~~~
NelsonMinar
And Python's integer_type is gold-plated.

~~~
gshubert17
Does that make pypy_platinum?

time pypy -c_"print sum(xrange(1000000001))"

is 2.0 seconds on my_Mac;_a C program_with_8-byte_ints (long_or long long)
takes_2.6_seconds.

------
terranstyler
Posted on_stackoverflow,_what an irony...

~~~
recursive
There's no stack overflow_or_even numeric overflow here. This is a_floating
point precision problem.

~~~
terranstyler
Ted Hopp_thinks_it is transformed to_float in order to avoid_an SO. Unless you
know better, the_irony is_valid!

------
michaelochurch
Clojure:

 _  
    
    _   (reduce + (range_1000000001))
   _

Written that_way,_though, it takes_a_long time_(108 sec, compared to 2.6 sec
in C)._So that's_not fast, as elegant