(defun recur (m n)
(if (= n m)
(progn
(dotimes (i m)
(write-string "*"))
(terpri))
(progn
(dotimes (i m)
(write-string "*"))
(terpri)
(recur (incf m) n)
(dotimes (i (- m 1))
(write-string "*"))
(terpri))))
You must be retarded. I've written this in four minutes and I have exactly one week of Java experience. You already have the algorithm, just do it the same fucking way, unless you're too stupid to use a for loop. In that case, kill yourself.
Name:
Anonymous2012-02-22 13:54
More text triangles? Is Kodak still practicing?
Name:
Anonymous2012-02-22 17:03
>>3
How do you configure Emacs to indent branches of the if macro by two spaces instead of four?
Name:
Anonymous2012-02-22 17:07
>>8
I bet you can't tell me the basic algorithmic framework that was used for my triangle code! Yes, it's that fucking elite, because I can draw pretty much any triangle based off that framework.
>>11
Vim doesn't even have Lisp-aware indenting. It also doesn't have paredit mode or colorized faces, and it doesn't work inside eshell so I have to open a separate terminal. Why would I use it?
Name:
Anonymous2012-02-22 18:57
>>7
>I've written this in four minutes and I have exactly one week of Java experience
Sure...
Name:
FEAR_MY_TRIANGLE2012-02-22 19:29
#include <iostream>
using namespace std;
int main(void)
{
int r, c;
int n = 9;
for (r = 1; r <=n; r++, cout << endl)
for (c = 1; c <=n; c++)
cout << (r == 1 || r == n ||
(r <= c && r + c <= n + 1) ||
(r >= c && r + c >= n + 1 ) ? '*' : ' ');
return 0;
}
Name:
Anonymous2012-02-22 19:33
Programming newfag here.
If the code has a for/while loop, can it still be considered as a recursion?
>>15
A recursive function is allowed to have a loop in it, but that would be kind of confusing. Loops and recursion are two high-level ways of looking at the same thing. You generally pick one or the other to implement a particular algorithm so someone reading the code doesn't have to mentally translate between the two to figure out what's going on.
If loops are the only control flow being used, like in >>14, then it's not recursion at all!
Name:
Anonymous2012-02-22 20:33
>>17
How do you figure you no talent bitch? There are some depth and breadth first search algorithms that have for loops in the the recursion. If I wouldn't know better, I would almost thing that you are kind of slow when it comes to computer programming.
>>19
Don't get all defensive just because he called you out. Admit you were wrong and let him feel your tits. And then, go back to school and learn to use a computer.
Name:
Anonymous2012-02-22 20:50
inb4 Kodak-san derails the entire thread for 100 posts
Name:
Anonymous2012-02-22 20:53
>>22
Huh? Tell us again how using a for loop in recursion is confusing you no talent bitch.
>>18 There are some depth and breadth first search algorithms that have for loops in the the recursion.
I'm sure there are. Can't think of any right now. Say what you like about my failure to memorize all the algorithms I might ever need instead of consulting my books now and then.
Anyway I would argue that such algorithms are probably confusing. Wanna post a couple?
Name:
Anonymous2012-02-22 20:56
pearls before swine in hipster coffee hmmm I wonder how that will turn out
Name:
Anonymous2012-02-22 20:58
>>25
Your problem is that you don't think before you post.
public class Main {
private static recur(int m, int n) {
if(m == n) {
for(int i = 0; i < m; i++) System.out.print("*");
System.out.println();
}
else {
for(int i = 0; i < m; i++) System.out.print("*");
System.out.println();
recur(++m, n);
for(int i = 0; i < m - 1; i++) System.out.print("*");
System.out.println();
}
}
public static void main(String[] args) {
recur(3, 5);
}
}
Name:
Anonymous2012-02-23 5:31
>>16
Not true. I take it you haven't red you're SICP today?
Name:
Anonymous2012-02-23 10:00
>>33 haven't read you're SICP you're SICP
I AM SICP, MOTHERFUCKER