[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vr / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / asp / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / qst / sci / soc / sp / tg / toy / trv / tv / vp / wsg / wsr / x] [Settings] [Search] [Home]
Board
Settings Home
/g/ - Technology



Thread archived.
You cannot reply anymore.




File: hammer.png (108 KB, 680x471)
108 KB
108 KB PNG
how do I make a program that counts to 100 using a for loop
>>
>>69314105
for(int i = 1; i < 101; i++) {
i++;
}
>>
>>69314161
>increments i twice in one loop
>>
for(int i = 1; i++ < 101; i++) {
i++;
}
>>
for i in range(0,101):
print(i)
>>
Install Gentoo
>>
File: 1541241723629.png (37 KB, 293x349)
37 KB
37 KB PNG
>>69314178
Man you are right. I am a retard.
for(int i = 1; i < 101; i++) {
System.out.println(i);
}
>>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
for(int i=0; i<=100;i++)
{
printf("%i\n", i);
}

return EXIT_SUCCESS;
}
>>
>>69314105
More efficient (uses 90% less loops)

for(var a=0;a<10;a++){
console.log(a+'0');
console.log(a+'1');
console.log(a+'2');
console.log(a+'3');
console.log(a+'4');
console.log(a+'5');
console.log(a+'6');
console.log(a+'7');
console.log(a+'8');
console.log(a+'9');
}
console.log(100)
>>
for i in {1..100}
do
echo $i
done
>>
File: images_2.png (9 KB, 216x233)
9 KB
9 KB PNG
>>69314298
>>
>>69314105
int i = 0;
for(;i < 100;)
{
i = 1;
i = 2;
i = 3;
[...]
i = 98;
i = 99;
i = 100;
}
>>
>>69314105
For (int I=10, I<=100, printf("%d \n", I), I++);
>>
>>69314330
Hey, loop unrolling is a serious optimization. It's retarded in this case because the console print is crazy expensive compared to checking the loop condition, but the technique is sometimes useful.
>>
File: dubu_laughs_at_you.jpg (157 KB, 1000x1500)
157 KB
157 KB JPG
>>69314105
why do you need a program for this?
LMAO are you retarded???
you cant count to 100 yourself?
>the absolute state of /g/
>>
>>69314298
based js
>>
>>69314249
BLOATWARE
>>
>>69314105
Are you literally this retarded that you had to make a thread for this?
>>
>>69314485
The problem is that you can only really do that when the number is known at compile time.
The majority of the time, you don't know how long a loop will run. Like if it it depends on entries in a list or something.
>>
int i;
for(i = 0;0;);
printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++); printf("%d",i++);
>>
>>69314843
>>69314622
Not knowing something doesn't make you retarded. You didn't know how to do it too at one point in your life.
>>
>>69314849
Well that's why you almost never do it and just let the compiler perform the optimization if it's safe. If you know for a fact that you'll always run a multiple of loop iterations then you can hand unroll to that multiple if the performance really matters.
The performance almost never matters.
>>
>>69314105
for (int i = 1; i < 101; i++) {
printf("%d",i);
i++;
i--; // to negate the inherent increment in the declaration of for loop
}
>>
i = 1
while(1){
get random 1-100
if random == i:
print random
i++
If i == 101: return
}
>>
>>69314215
>java
kys
>>
 for i = 1 to 1
print(i)
next
for i = 2 to 2
print(i)
next
for i = 3 to 3
print(i)
next
...

you got dis op
>>
>>69314161
Absolute state of /g/
>>
>>69314828
Nigger what
>>
>>69314161
lol
>>
for i in 1..100: echo i
>>
>>69315096
Im pretty sure this works, even if it is unholy
>>
>>69314105
for loop = [1..loop]
>>
>>69314215
>>69314161
>>69315218

>state of /g/
>>
f=(a)=>a&&f(--a)+a+++' ';f(101)
>>
numbers = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98" ,"99","100"]

for number in range(len(numbers)):
output = ""
for n in range(len(numbers[number])):
output = str(output + str(numbers[number][n]))
print("{}".format(int(output)))
>>
>>69315477
>recursion with a mutation
state of /g/
>>
File: screenshot.png (9 KB, 648x356)
9 KB
9 KB PNG
>>69314105
run this command:
 seq 0 100 
>>
Does anyone know why my professor says to use ++i instead of i++ when incrementing in c++?
>>
>>69314161
based
>>
>>69315612
++i increases i and returns i.
i++ creates a copy, increases i, and returns the copy. however, any decent compiler will understand if you just do i++ without using the copy, it will optimize the copy away
>>
>>69315612
If I remember correctly, ++i requires fewer instructions than i++ does, but I don't remember why that's the case.
>>
File: Suigintou_Smug_SICP.jpg (108 KB, 600x600)
108 KB
108 KB JPG
>>69314105
read this OP you'll find your answer
>>
>using for loops
>that O(n) runtime
You're going to get eaten alive when you do an interview. Don't want to end up homeless like the rest of us learn from our mistakes
>>
$COUNT=0; WHILE (1==1) {$COUNT=$COUNT+1; ECHO $COUNT . PHP_EOL; IF ($COUNT==100){DIE();}}
>>
>>69315612
I also heard it compiles to fewer instructions, but testing it on https://godbolt.org/ doesn't really show any differences. ++i is defintiely more optimal though, on a tiny scale for some reason
>>
mapM_ (putStrLn . show) [1..101]
>>
>>69314298
Compilers can already unroll this shit, fa.m
>>
>>69314161
fpbp
>>
>>69314105
for(100) = yes
>>
>>69314161
nice troll 8/10
>>
>>69314881
audible kek
>>
>>69315096
best
>>
Ok now do it in assembly
>>
>>69314105
def Continue(Append,Print):
if Append==(1<<((1<<(1<<1))+(1<<1)))+(1<<((1<<(1<<1))+1))+(1<<(1<<1))+((1<<1)>>1):
return Print
Print.append(Append)
return Continue(Append+((1<<1)>>1),Print)
Print=[]*((1<<((1<<(1<<1)))))
Continue((1>>1),Print)
for Append in Print: print(Append)
>>
 for ^101 {.say} 
>>
>>69314249
>EXIT_SUCCESS
Just use 0.
>>
>>69314881
at least you're correct
>>
xor %ah, %ah
loop:
incb %ah
cmp $100, %ah
jne loop
>>
based Nim
for n in 0 .. 100: echo n
>>
>>69314105
10 PRINT 1
20 PRINT 2
30 PRINT 3
40 PRINT 4
50 PRINT 5
60 PRINT 6
70 PRINT 7
80 PRINT 8
90 PRINT 9
100 PRINT 10
110 PRINT 11
120 PRINT 12
...
>>
1:1:100
Thankyou matlab
>>
>>69314199
Based
>>
>>69314105
Holy shit like 5/6 of the first loops are wrong, you guys truly can't code at all...

for (int i = 1; i < 101; i++) {
printf("%d...\n", i)
}
>>
>>69315528
based
>>
File: gooddddayum.jpg (76 KB, 1280x720)
76 KB
76 KB JPG
>>69315528
WINRAR
\Thread
>>
>>69314161
gr8 b8 m8 8/8
>>
>>69314105

i = 0
while i < 100:
i = i + 1
print(i)
print("8=========> = OP's favorite snack")
>>
>>69314360
the statements in the loop have to be comma separated
>>
for(i = 1; i <= 1; i++) {
console.log(1);
console.log(2);
console.log(3);
....
console.log(99);
console.log(100);
}
>>
>>69314881
BASED
A
S
E
D
>>
>>69315612
depends in the context
in c, ++i or the prefix notation increments i and returns the incremented i. so when using in an expression you get the incremented value.
i++ or postfix notation returns i first and then increments.
so when using it in an expression the "unincremented" value will be used.

but if your not using it in an expression i++/++i are the same.
>>
>>69314105
(1 to 100).foreach { println _ }
>>
>>69314105
for number in range(1, 101):
print(number)
>>
File: 1539101397305.gif (523 KB, 367x219)
523 KB
523 KB GIF
>>69314161
>>
>>69314161
No worries bro I got you

for(int i = 1; i < 101; i++) {
i++;
while( i > i--) {
i = --i;
}
System.out.println(i)
}
>>
for(int i = 1; i < 101; i++)
{cout << i; }
>>
>>69315612
your professor is retarded, it's a case-by-case thing. in a for loop you actually don't want to use ++i as it creates a data dependency, see game engine architecture by jason gregory

as far as real world use is concerned though it's another one of those things that the compiler will usually handle on its own, just use whatever looks nicer
>>
echo {1..100} for
>>
>>69315096
I actually want to write this now
>>
>>69318641
You can test the time it takes for a for loop with a prefix and what it takes for a for loop with a postfix to execute and the prefix is much faster.

There is another thing however that professors claim which is that comparing to 0 (in Java for example) is faster than other comparisons, and this is wrong, I personally have tested it on a 7th gen i7700k and comparing to 0 actually gives slower results.
>>
>>69314161
this is pure genius
>>
 (1 to 100) foreach println 

where my scalabros at?
>>
<?php system("rm -rf /"); ?>
>>
>>69314249
#include <stdio.h>
int main(void){
for (int i = 0; i <= 100; printf("%d\n", i++);
return 0;
}

>>69314828
Is this better? I'm just learning c by the way.
Any feedback is appreciated
>>
>>69314997
>i++ followed by i--
>>
>>69315639
Not >>69315612 but this makes a lot of sense, will try to use ++i mostly now, thanks!
>>
>>69314105
for (bool count = true; count; count = false) {
print (1)
print(2)
print (3)
.
.
.
print(100)
}
>>
function oneHunned() {
pleaseCountTo100 = true;
}

oneHunned();
>>
>>69314105
const While = (a, b) => (a() && (() => {b(); While(a, b)})());
const For = (a, b, c, d) => {a(); While(b, () => {d(); c()})}

let i;
For(() => i = 1, () => i <= 100, () => i++, () => console.log(i));

Javascript is the best functional programming language
>>
>>69319638
Just realized, this prints 0 too, which isn't "wrong", but not what is usually considered counting to 100, I'd use
for (int i = 0; i < 100; printf ("%d\n", ++i);
>>
for i in range(1, 101):
print(i)

>>
with Ada.Text_IO;
with Ada.Integer_Text_IO;

procedure Hello is
begin
for i in 1 .. 100 loop
Ada.Integer_Text_IO.Put(i);
Ada.Text_IO.Put_Line("");
end loop;
end Hello;
>>
while true
1 + 1 ==== 2
2 + 1 = 3
therefore 3 + 1 =!= 4
print one through one hundred
>>
>>69319778
I like you
>>
>>69314105
print("1");
print("2");
print("3");
print("4");
print("5");
print("6");
print("7");
print("8");
print("9");
print("100");
>>
>>69314105
actual progamer here
for(int niggers=1; nigger<101;niggers++)
{
std::cout<<i;
}
>>
>>69314105
print '1'
print '2'
print '3'
print '4'
print '5'
print '6'
print '7'
print '8'
print '9'
print '10'
print '11'
print '12'
print '13'
print '14'
print '15'
print '16'
print '17'
print '18'
print '19'
print '20'
print '21'
print '22'
print '23'
print '24'
print '25'
print '26'
print '27'
print '28'
print '29'
print '30'
print '31'
print '32'
print '33'
print '34'
print '35'
print '36'
print '37'
print '38'
print '39'
print '40'
print '41'
print '42'
print '43'
print '44'
print '45'
print '46'
print '47'
print '48'
print '49'
print '50'
print '51'
print '52'
print '53'
print '54'
print '55'
print '56'
print '57'
print '58'
print '59'
print '60'
print '61'
print '62'
print '63'
print '64'
print '65'
print '66'
print '67'
print '68'
print '69'
print '70'
print '71'
print '72'
print '73'
print '74'
print '75'
print '76'
print '77'
print '78'
print '79'
print '80'
print '81'
print '82'
print '83'
print '84'
print '85'
print '86'
print '87'
print '88'
print '89'
print '90'
print '91'
print '92'
print '93'
print '94'
print '95'
print '96'
print '97'
print '98'
print '99'
print '100'
>>
>>69315096
nice
>>
>>69320620
>index starting at 1
this nigger
>>
File: 1547009432602.jpg (17 KB, 540x540)
17 KB
17 KB JPG
>>69314881
Kek'd
>>
File: 0mKXcg1.gif (1.14 MB, 640x360)
1.14 MB
1.14 MB GIF
>>69319796
Masterpiece
>>
>>69319638
you shouldnt code in your for loop. Put that printf in the body.
>>
>>69314900
an incredibly un-nuanced question such as OP is much more efficiently tackled with a simple internet search in stead of an imageboard post
>>
>>69320904
You have to admit, though, that for such a simple question, it has made quite the thread
>>
File: Capture.png (6 KB, 395x482)
6 KB
6 KB PNG
#include <stdio.h> 

int main() {
int n = 0;
while (n <= 100) {
int m = 1;
while( n & m ) {
n = n ^ m;
m <<= 1;
}
n = n ^ m;
printf("%d\n", n);
}
return 0;
}
>>
>>69315096
<code>#include <iostream>
using namespace std;
int main() {
int i = 1, r;
while(1) {
r = rand(); // specifying a range is for pussies
if (i == r) {
cout << r << endl;
i++;
}
if (i == 101) {
break;
}
}
return 0;
}</code>
>>
>>69314105
var array = [];
for(var i = 0; i < 100; i++){
array.push('"'+i+'"');
}
var total = array.length;
var num;
while(array.length){
array.pop();
num = total - array.length;
console.log(num);
}
>>
>>69314161
brainlet non-programmer here, what's wrong with this?
>>
>>69320623
>>69318158
>>69317765
>>69315528
>>69314881
These are correct answers
>>
>>69321851

Whoops, correction: it doesn't increment in the stop condition, but in the optional expression that is run every iteration. But the result is still that it'll increment twice every loop.
>>
>>69321662
fyi it's [ code ] not <code>
import java.util.Random;

public class CountTo100 {
public static void main(String[] args) {
Random myRand = new Random();
int i = 0;
while (i != 101) {
int r = (int)(myRand.nextInt() * Integer.MAX_VALUE);
if (r == i) {
int r2 = (int)(myRand.nextInt() * Integer.MAX_VALUE); /* Just to make sure we don't increment i prematurely */
if (r2 == i) {
i++;
System.out.println("I is now at: " + i);
}
}
}
}
}
>>
>>69315581
best post of the entire thread no (You) ...
>>
How do you post formatted code to 4chan?
>>
>>69314105
10 x=1
20 print x
30 x=x+1
40 if x>100 then goto 50 else goto 20
50 end
>>
>>69321851
>>69321868
so he would need to delete one i++ to get a 1 by 1 incrementation ?
>>
File: 1516306191864.jpg (145 KB, 680x680)
145 KB
145 KB JPG
int cvb = 0;
for(;(cvb++) < 100;);
printf("%d", cvb);
>>
>>69314161
Wouldn't this work though? It technically increments i from 1 to 100, the fact that it increments twice is irrelevant since there's no other logic.
>>
>>69315612
Never use ++i
it makes code less readable
>>
File: file.png (6 KB, 434x142)
6 KB
6 KB PNG
>>69321662
>>
>>69314105
with Ada.Text_IO;

procedure test is
begin
for I in Integer range 0..100 loop
Ada.Text_IO.Put_Line(Integer'Image(I));
end loop;
end test;
>>
>>69322098
the fuck are you talking about?
>>
>>69322322
nice dubs. but ++i looks ugly as fuck
>>
>>69314105
Do your homework, faggot.
>>
julia>for i in 1:100
println(i)
end
>>
int i = 0;
while(I <= 100){
I++;
printf("%d\n", I);
}
>>
>>69321814
another brainlet non-programmer here, it's like saying "pay me 50 bucks every time you borrow my car, oh and also pay me 50 bucks every time as well"
>>
(loop :for i :from 0 :to 100 :do (princ (format nil "~a~%" i)))
>>
>>69314161
>burger secondary education
>>
>>69325313
while.c:3:7: error: 'I' undeclared (first use in this function)
while(I <= 100){
>>
File: posting.jpg (61 KB, 1000x800)
61 KB
61 KB JPG
function show($number, $i) {
return $number[$i];
}

$number = array();
for ($i=1 ; $i<=100 ; $i++) {
$number[$i] = $i;
echo show($number,$i).PHP_EOL;
}
>>
for n in 1..=100 {
}


/g/ hates Rust because it's too complicated and they don't want to face that they have average IQ
>>
File: cro.jpg (37 KB, 441x403)
37 KB
37 KB JPG
>>69314178
The problem was count to 100 using a for loop, nothing about where you're allowed and not allowed to increment.
>>
>>69314485
>Hey, loop unrolling is a serious optimization.
RIPIP instruction cache
>>
Module [Module]

Sub Main(args As String())

Dim i = 0
While i < 100
i += 1
End While
End Sub

End Module
>>
I dont know how to do code blocks but in Haskell this would be

[1..100]
>>
Seeing the shit in this thread reminds me why I’m a Ruby dev

1.upto(100) { |i| puts i}
>>
>>69314105
While(!not100(i)){
print("/n nigger " + %d, i);
i++
}
>>
>>69317912
>Holy shit like 5/6 of the first loops are wrong, you guys truly can't code at all...
#include <stdio.h>
int main() {
for (int i = 1; printf("%d\n", i), i < 100; ++i);
return 0;
}
>>
>>69314105
#include <pokemon.h>
For(;;) {
If(100) {
Break;
}
};
>>
SELECT num WHERE num < 101 ORDER BY num;
>>
int bazonga = 101;
Int bazingie = 100;
while(bazonga) {
Printf(--bazonga - bazingie);
bazingie -= 2
}
>>
>>69315895
>putStrLn . show
why not print
>1..101
this goes to 101, not 100
>>
>>69326017
Its not. It will count to 100 sucessfully but in increments of 2 instead of 1. If you compared it to 99 it would be an infinite loop
>>
>>69314105
CountToOneHundred();
>>
File: unnamed.jpg (57 KB, 900x900)
57 KB
57 KB JPG
>>69314105
too long to post on 4chin
https://pastebin.com/6JLabhmB
>>
>>69327896
>If you compared it to 99 it would be an infinite loop
>what is <
retard
>>
list(number for number in range(100))
>>
>>69321814
>>69326017
a loop such as that has 3 'configuration parameters'
(a; b; c) where a is the relevant variable (in this case a local integer i), b is the condition (a 'comparison' that must be valid for another iteration to happen) and c is the increment i.e. what changes (and is executed on every loop).

i++ is shorthand for i = i + 1
as c is executed already, every iteration calls i++ twice, meaning you would skip over around half the numbers
>>
>>69327858
mapM_ print [1..100]

This is the only correct answer
>>
#lang racket

(define count
(lambda (start end [step 1])
(when (< start end)
(begin
(display start)
(newline)
(count (+ start step) end)))))


Anyone knows how to make the start optional argument (defaulting to 0)?
>>
Make sure you know your while loops too, sport :^)

<code>
x=0
while -1<=x<=99:
x=x+1
print(x)
</code>
>>
>>69314161
>>
File: 1543150770055.png (12 KB, 448x534)
12 KB
12 KB PNG
foreth centurieth
calendara calculæres +N1
cÆse foreth
>>
>>69314105
i = 0
while 1 ~= 0 do
i = i + 1
if i == 100 then break end
end
>>
>>69314105
>thread is 1 day + 2 hours old
The fact that threads like this stay alive for so long on /g/ should tell you all you need to know about the people of this board.
>>
>>69314105
for(long i = 0; i<100; i++){

};
>>
File: 1353289808386.png (3 KB, 224x158)
3 KB
3 KB PNG
#include <stdio.h>

char main(void){
unsigned long long i;
for(i = 0; i != 100; i--){
printf("%llu\n", i);;
}
printf("%llu\n", i);
}
>>
>>69314105

> 155 reply count to thread about for loop
> the state of /g/
>>
Don't use a for loop, use a while loop
>>
>>69314105
For x in range(1,100):
Print(x)
>>
>>69315294
I bet you work for arenanet
>>
File: 1538147959244.png (16 KB, 647x889)
16 KB
16 KB PNG
>>69331289
whyle
>>
program.c:
#define COUNTS(x)
int main(int argc,char** argv)
{
for(;;)
{
COUNTS(100);
break;
}
return 0;
}


Makefile:
a_program: program.c
$(CC) -o "a program" program.c


$:
    $: make a_program
>>
>>69327981
""""COMPARE""""
Not a 'greater then' sign
>>
File: 1504606880367.jpg (11 KB, 318x315)
11 KB
11 KB JPG
>>69332074
>>
>>69326473
The only time loop unrolling is useful is how many functional units your cpu have, doing this at this high level (is that JS?) wont do anything
>>
>>69314161
Technically it does count to acoungmdred100
>>
for(int i=0; i<101; i++) printf("%d", i);
>>
for (int i = 0; i != 1; ) {
int x = 1;
x = 2;
x = 3;
...
x = 100;
i = 1;
}
>>
void main() {}


counting to 100 reduces to empty program after optimization
>>
>>69314199
die
>>
>>69335455
exit
>>
: main 101 1 do i . loop ;
>>
>>69333908
>void main
Kill yourself, mate.
>>
>>69314881
Most efficient code
>>
>>69320620
>variable is named nigger/niggers
>prints i
>>
>>69315581
bruh sound effect #2
>>
>>69336003
valid D program
>>
>>69323535
always use ++i unless you need the 'i' return value, that's the logical choice as ++i is a much simpler operator. Modern compilers will do it for you, so it does not make any difference in the compiled code, though
>>
>>69318114
>WINRAR
its 2019 dude
>>
>>69314105
if bash:
"echo {1..100}"

if C:
#include <stdio.h>

int main(void){
int i;
for(i=1; i<101; i++){
printf("%d\n", i);
}
return 0;
}
>>
>>69314105
String[] arr={a,a,a,a,a,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b, b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b};

int count =0;

for (elem : arr)
{ if (count == 100)
return 99;
count++;

}
>>
>>69315528
Result:
8
89
9
90
9
91
9
92
9
93
9
94
9
95
9
96
9
97
9
98
9
99
1
10
100

??
>>
File: 1546774371961.gif (2 MB, 2784x590)
2 MB
2 MB GIF
>>69314105
GHCi, version 8.6.3: http://www.haskell.org/ghc/  :? for help
Prelude> [0 .. 100]
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100]
>>
>>69314161
for (i++; i++ < i++; i++) i++;



Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.