Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++

Name: Anonymous 2010-04-17 17:20

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 Swan 2010-04-18 11:24

Hax my anus, Edward Cullen!

Name: Anonymous 2010-04-18 12:36

>>37
Hey! You can't have BBCODE in the thread subject!!!!

Name: Anonymous 2010-04-18 12:44

,------------------------------------------------>++++++++++++++++++++++++++++++++++++++++++++++++>+<<[>>[>+>+<<-]>>[<<+>>-]<[<<+.>>-]++++++++++.----------<[>+>+<<-]>>[<<+>>-]<[<<->>-]<+<< -] 

VALID BF CODESadly it only works upto 9 ;_;

Name: Anonymous 2010-04-18 12:47

>>43
BB[code] FAILURE

,------------------------------------------------>++++++++++++++++++++++++++++++++++++++++++++++++>+<<[>>[>+>+<<-]>>[<<+>>-]<[<<+.>>-]++++++++++.----------<[>+>+<<-]>>[<<+>>-]<[<<->>-]<+<< -]


VALID BF CODE Sadly it only works upto 9 ;_;

Name: sega 2010-04-18 17:50

Hey, /prog/.  Your board sucks dick.  Just sayin'.

Name: Anonymous 2010-04-18 23:38

>>45
I'm glad you think that. I am totally not being facetious.

Name: Anonymous 2010-04-19 1:39

b:\>perl -E "say 1..$_ foreach 1..7"
1
12
123
1234
12345
123456
1234567

b:\>

Can your FIOC do that? Can it?! Hah.

Name: Anonymous 2010-04-19 1:49

>>47
[print(*range(1, i+1), sep="") for i in range(1, 8)]

Name: Anonymous 2010-04-19 2:16

[code]
#include <iostream>
using namespace std;

int main() {
    int wut;
    cin >> wut;
    for (int a = 1; a <= wut; a++) {
        for (int b = 1; b <= a; b++) {
            cout << b;
        }
        cout << endl;
    }
}

Name: Anonymous 2010-04-19 3:44

>>40
Kind of cold but true
& you can also say that
Reading the other parts of this epic epic would do you even more good

Name: Anonymous 2010-04-19 5:29

>>47
Prelude Control.Monad Data.List> forM_(inits[1..7])print
[]
[1]
[1,2]
[1,2,3]
[1,2,3,4]
[1,2,3,4,5]
[1,2,3,4,5,6]
[1,2,3,4,5,6,7]
Prelude Control.Monad Data.List>


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>

Name: Anonymous 2010-04-19 5:31

>>47
My faggot hipster language can:

[code
ruby -e '(1..7).each{|i|puts((1..i).to_a.join)}'
[/code]

Name: Anonymous 2010-04-19 5:32

>>52
IN BEFORE BBCODE FAILURE DETECTED


ruby -e '(1..7).each{|i|puts((1..i).to_a.join)}'

Name: Anonymous 2010-04-19 6:08

(for-each (lambda (x) (for-each display x) (newline))
          (list-tabulate 7 (lambda (x) (iota (add1 x) 1))))

or
(do-ec (:range i 1 8)
         (begin                     
           (do-ec (:range j 1 (add1 i))
                  (display j))
           (newline)))

Name: Anonymous 2010-04-19 6:44

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: Anonymous 2010-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: Anonymous 2010-04-19 7:59

>>55 HAPPY NOW FAGGOT

ruby -e '(1..ARGV[0].to_i).each{|i|puts((1..i).to_a.join)}'

Name: Anonymous 2010-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.

Name: Anonymous 2010-04-19 8:21

>>57 YES THANK YOU

Name: Anonymous 2010-04-19 8:41

>>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.

Name: Anonymous 2010-04-19 9:01

>>58
try factor:
( scratchpad ) : hw ( n -- ) [1,b] [ [1,b] [ pprint ] each nl ] each ;
( scratchpad ) 7 hw
1
12
123
1234
12345
123456
1234567
( scratchpad )

Name: Anonymous 2010-04-19 9:20

>>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.

Name: Anonymous 2010-04-19 11:13

>>62
most ruby coders don't really read any code. they just copy and paste bits of code from random blogs until it does what they want.

Name: Anonymous 2010-04-19 11:55

>>63
and so life imitates art

Name: Anonymous 2010-04-19 11:58

>>62
APPLES AND ORANGES
The perl solution is limited to 1..7 , where as the ruby solutions provides ENTERPRISE GRADE FLEXIBILITY

Name: Anonymous 2010-04-19 12:26

>>47
can your line noise do this?
take <$> [1..7] <*> [[1..]]

Name: Anonymous 2010-04-19 12:30

>>66
or even better:
take 7 $ take <$> [1..] <*> [[1..]]

Name: Anonymous 2010-04-19 12:53

x := input

while x > 1:
   x = floor(x/10)
   print(x)

Not sure I understand OP's question right but that's how I'd do it.

Name: Anonymous 2010-04-19 13:13

>>68
I don't think you did..

Name: Anonymous 2010-04-19 13:18

-accelerated c++
-the c++ programming language (the bible, form Stroustrup)

Name: Anonymous 2010-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

Name: Anonymous 2010-04-19 16:40

>>71
Please die.

Name: Anonymous 2010-04-19 16:53

>>72
@71 lol i think you'd like me if you got to me. i've just been to the grocery store to by some supplies

Name: Anonymous 2010-04-19 16:56

>>73 see >>72

Name: Anonymous 2010-04-19 18:07

.say for[\~]1..6

Name: Anonymous 2013-09-01 14:51


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.

Name: Anonymous 2013-09-01 14:57

>>75
[\~](1..6).say;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List