For an assignment I need to have a program print the inputted number, and every number before it in sequence ex:
1
12
123
1234
12345
123456
I can get it to print a list of the number but for the love of god I cant get it to print the numbers before hand. I know theres a simple way to do it nesting a while loop in a for loop but I can't fucking figure it out.
Help for a poor retarded aspiring programmer?
Name:
Bella Swan2010-04-18 11:24
Hax my anus, Edward Cullen!
Name:
Anonymous2010-04-18 12:36
>>37
Hey! You can't have BBCODE in the thread subject!!!!
or if you want it to look nice: Prelude Control.Monad> forM_[concatMap show[1..x]|x<-[1..7]]putStrLn
1
12
123
1234
12345
123456
1234567
Prelude Control.Monad>
Can someone please tell me why all these people are printing the numbers from 1 to 6 as if the OP didn't specify the number has to be inputted and it's not always 6?
Also what IS the difference between List and Data.List?
Name:
Anonymous2010-04-19 6:49
Also what IS the difference between List and Data.List? http://en.wikibooks.org/wiki/Haskell/Hierarchical_libraries When Haskell 98 was standardised modules were given a flat namespace. This has proved inadequate and a hierarchical namespace has been added by allowing dots in module names. For backward compatibility the standard libraries can still be accessed by their non-hierarchical names, so the modules List and Data.List both refer to the standard list library.
Name:
Anonymous2010-04-19 7:59
>>55 HAPPY NOW FAGGOT
ruby -e '(1..ARGV[0].to_i).each{|i|puts((1..i).to_a.join)}'
Name:
Anonymous2010-04-19 8:08
I love it how perl, considered here the most line noisy language among all popular provides the most concise and readable solution for the problem. Just have a look at that punctuation-fest ruby.
>>58
Readability depends very much on exposure to the language. When I saw the perl solution I was thinking "WTF is $_", although it was easy enough to figure out as we were given the solution. IMO, the most readable ones are in the C-style with explicit loops.
>>60
My point is that even knowing language, you still have to read the whole program to guess what it will do. The larger it is, the more you'll spend on processing it. say 1..$_ foreach 1..7 is the the easier to process for perl programmer than (1..ARGV[0].to_i).each{|i|puts((1..i).to_a.join)} is for ruby coder.
-accelerated c++
-the c++ programming language (the bible, form Stroustrup)
Name:
Anonymous2010-04-19 13:24
@69 Lol hy think you did my anus lol lets all do twitter style replies because it's so hipster and cool and written in ruby which is also hipster and cool
Arithmetic operations similar to those given below for the extended real numbers can also be defined, though there is no distinction in the signs (therefore one exception is that infinity cannot be added to itself). On the other hand, this kind of infinity enables division by zero, namely z/0 = \infty for any nonzero complex number z. In this context it is often useful to consider meromorphic functions as maps into the Riemann sphere taking the value of \infty at the poles. The domain of a complex-valued function may be extended to include the point at infinity as well. One important example of such functions is the group of Möbius transformations.