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


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: lisp.jpg (26 KB, 680x383)
26 KB JPG
"I use loops", said Linux Kernel creator Linus Torvalds, when asked about new trends.

"You can't write programs without loops", he added.

our answer, lisp-sisters?
>>
I love for loops
>>
>>109007048
AI is superior.
>>
>>109007048
https://youtu.be/peXNAwzyJas?is=sjIlWANTkjzVcQJx
>>
>>109007048
>Have to iterate through an array
>Can't use anything resembling a loop
How would you even do that?
>>
>>109007048
> gentoo_funroll-loops.png
>>
>>109007048
>our answer, lisp-sisters?
what do you think loop macro is exactly?
>>
>>109007216
use a map method... which probably internally uses a loop kek
>>
>>109007048
>lisp-sisters
(loop
(print "Hello")
(return 42)) ; Exits immediately and returns 42

we use loops.
>>
>delusional lisp fag thinks tail recursion isn't just an awkward way to make a loop
>>
>>109007048
CL literally has a loop DSL macro lmao
It’s better than the C-style for loop and if you don’t like it then there’s the do macros
>>109007602
>idiot doesn’t know that loop isn’t recursive
>>
When did the clean code cult started to hate loops?
>>
>>109007758
neither is tail recursion, it's just a goto with none of the elegance of a proper recursive function
it's a tranny loop that deluded xerself into thinking it's not a loop
>>
>>109007932
Wanna know how we know you have no idea what tail recursion actually is?
>>
>>109008858
NTA, but stop being a retard.
>>
>>109007048
who cares about a C programmer
actual good OSes should be written in Lisp
>>
It's mostly javascript developers that hate loops for some reason.
They will even use map over loop even when they know it's slower.
>>
>>109007932
Bro you should first read a book about PLT, you obviously don't know much about iteration, lambda expression and loop statement.
>>
>>109007048
You have never used Lisp.
>>
>>109007048
https://www.lispworks.com/documentation/HyperSpec/Body/06_.htm
>>
>>109009273
javascript creator was a lisp programmer
>>
>>109007048
personally, I don't care for them
>>
>>109009573
irrelevant, modern webfags have nothing to do with Eich
>>
>>109009623
javascript was designed after lisp
>>
Iteration trans will be the first ones to go on day of the ACK
>>
>>109007216
Theoretically speaking on a very general level, you can't

But in practice:
One way is to unroll the loop, your code will be a lot less space-efficient, but since there's no jump back to an earlier instruction, there's no loop.
Another way is to run your code on a highly parallel processor like a GPU. If the elements are all independent this is ideal. Each processor takes a different element of the array. No loop needed.
Midwits will say muh recursion. But truth be told the compiler will generate code that looks a lot like (or, often, exactly like) a loop. It's really just loops with an incredibly elegant way to express complex exit conditions.
>>
File: 1765554911655348.png (94 KB, 766x340)
94 KB PNG
>>109009819
>recursion
>>
File: 209348203948.jpg (124 KB, 1500x1000)
124 KB JPG
>>109009834
>not reading the post
>>
>>109007186
Hello pajeet! Did Sam Fagman pay you to spam this board with your aifag garbage? All I see is the samefag (you) posting this same picture over and over like you're paid the same as Israeli bots in /pol/. You aifags can go spam your garbage to the same dump you came from you fucking shartrannies
>>
File: 1708369525472900.jpg (72 KB, 1024x851)
72 KB JPG
>>109007048
>his program has state
>>
>>109009263
>actual good OSes should be written in Lisp
based
/thread
>>
>>109009819
>Another way is to run your code on a highly parallel processor like a GPU
Oh really? And how will you distribute N work slices to your parallel processors without counting to N? That's what I thought, BITCH.
>>
>>109009263
>actual good OSes should be written in Lisp
The last time that was tried, it failed so hard it wiped out the maker of the OS and the hardware.
Lisp weenies have been trooning out over it for decades. Perpetual losers.
>>
File: iterate.png (46 KB, 629x495)
46 KB PNG
>>109007216
Doesn't recursion counts?
>>
>>109010662
Like, recursion is more like a staircase inside a mirror, while a loop as a dancer tracing a circle on the floor.
>>
>>109007048
CL has the loop macro
Most scheme implementations have tail call optimization which in turn translates your recursion into a jump, literally what a loop does.
Such is my answer
>>
File: 1610849201277.jpg (502 KB, 1360x2108)
502 KB JPG
>>109007048
>>
>>109007932
>it's just a goto with none of the elegance of a proper recursive function
these are mathematically the exact same thing you fucking retard
a loop is just a cycle in a graph, same as a recursive function
>>
>>109010747
a recursive function can be a bit more complicated than a loop
>>
>>109009273
Skill issue on their side.
(f=>f(f,'',1))((f,m,i)=>i>100?m:f(f,(f='',i%3||(f+='Fizz'),i%5||(f+='Buzz'),m+(f||i)+'\n'),i+1))
>>
>>109010891
No, they have the exact same capacity of behavior. They are literally the exact same thing. You are confusing a specific mental model as the boundary of a very, very general and vague domain.
>>
>>109007048
 POST {
read { comprehead {
reply { draft
}}}
relpy {captcha { humiliated }}
SEND {..}}
>>
File: 1709113459353617.jpg (63 KB, 850x638)
63 KB JPG
>>109011041
>No, they have the exact same capacity of behavior. They are literally the exact same thing. You are confusing a specific mental model as the boundary of a very, very general and vague domain.
alright solve towers of hanoi without recursion and only loops right fukken now
>>
>>109007048
>Bruder, where are the looooops.
>>
>>109009263
Who cares about OS programming
actual computers should be controlled with the mind
>>
>>109007048
Let me guess, he writes trivial off-by-one garbage because he can't handle iterators? Fuck off.
>>
>>109007216
fn:
if empty list do something
else do something with first item of list and combine it with fn on rest of list

stack overflow potential? make it tail recursive
language doesn't have proper tail calls? use a real programming language
>>
>>109007932
I'm sensing a thoughtcrime that isn't very tolerant and diverse, xister.
>>
>>109009273
fold and its gang mog loops
>>
File: oh.jpg (264 KB, 800x808)
264 KB JPG
>>109011057
>>
>>109007932
I love lisp and recursion and will take them over any niggerlicious loop but this is true.
Making any recursive function tail recursive rapes it and makes it no better than a loop.

From SICP
"The observation that a tree-recursive process may be highly inefficient but often easy to specify and understand has
led people to propose that one could get the best of both worlds by designing a “smart compiler” that could transform tree-recursive procedures into more efficient procedures that compute the same result."
>>
>>109007216
like this
let iterate arr =
let size = Array.length arr in
let rec go i =
if i = size then (
()
) else (
Printf.printf "%d " arr.(i);
go (i + 1)
)
in
go 0;
Printf.printf "\n"

let () =
iterate [|1; 2; 3; 4; 5;|]

>>
>>109007048
lisp has loops, lilbro...
>>
>>109007932
>neither is tail recursion, it's just a goto with none of the elegance of a proper recursive function

"recursion is not recursion"

lel.
>>
Lol clueless poopjeets throwing poop at each other, poopfest the thread

Also linus is a cuck
>>
I unironically love how everyone missed what the OP is actually about. I'm a little ashamed that I get what buzzword xitter slop trend it's referencing
>>
>>109011103
"Any recursive algorithm can be rewritten iteratively" is literally compsci 101 you retarded nigger. The opposite is also true.
>>
>>109011447
>"Any recursive algorithm can be rewritten iteratively"
that is a strawman and moving the goalpost
I dont think you will pull it off in the 4 or so lines the recursive version takes
>>
>>109011480
code golf != good code
>>
>>109007048
based
>>
File: bröther.png (170 KB, 474x266)
170 KB PNG
>>109011724
>>
>>109007048
Everything is goto and condition goto from inside.
You can make it as pretty as you want, but it's all gotos.
>>
>>109011715
just because you can represent "everything" on a turing machine does not mean the abstractions on top of it are not meaningfully different
>>
>>109010576
>How will you do this thing that we figured out in the 1970's
Goddamn but you're a fucking retard. How did you not learn how to do this shit in your undergraduate CS programs? Because I learned this in as an undergrad in the mid 1980's, at a state university not even a top tier one.
https://www.cs.princeton.edu/courses/archive/fall20/cos326/lec/21-02-parallel-prefix-scan.pdf
>>
>>109011750
i can't hear you over your elegant recursive program blowing its stack
>>
>>109007048
Ya blew it.
Should've said Haskell sister instead.
>>
>>109011736
kek
>>
File: chalmers-simpsons.gif (39 KB, 512x364)
39 KB GIF
>>109009263
>actual good OSes should be written in Lisp
may we see them?
>>
Functional programming is intellectual masturbation. Nothing more.
>>
>>109011203
No it’s not. Maybe you should continue reading later chapters of SICP too.
>>
>>109014564
on it and I hope so
>>
>>109011103
n = 4
src = 'A'
aux = 'C'
des = 'B'

total_moves = 2 ** n - 1
if n % 2 == 0:
des, aux = aux, des

rods = { 'A': list(range(n, 0, -1)), 'B': [], 'C': [] }

for move in range(1, total_moves + 1):
if move % 3 == 1:
from_rod, to_rod = ('A', 'B') if (rods['A'] and (not rods['B'] or rods['A'][-1] < rods['B'][-1])) else ('B', 'A')
elif move % 3 == 2:
from_rod, to_rod = ('A', 'C') if (rods['A'] and (not rods['C'] or rods['A'][-1] < rods['C'][-1])) else ('C', 'A')
else:
from_rod, to_rod = ('B', 'C') if (rods['B'] and (not rods['C'] or rods['B'][-1] < rods['C'][-1])) else ('C', 'B')

disk = rods[from_rod].pop()
rods[to_rod].append(disk)
print(f"Move disk {disk} from {from_rod} to {to_rod}")
>>
>>109014022
>>
>>109011802
haskell doesn't have a call stack like that
>>
>>109009925
You idiot, Kernel is the lowest level and your stateless declarative meme nonsense is all based on real programming, which is imperative, full of hardcoded hex flags pushed in registers all over the place.
You write gay config files. System programmers who write in C are writing real code.
>>
why does theory trigger dunning-kruger retards so much
>>
my branch predictor said that any backwards jump is basically a loop
>>
the more loops within loops you stack, the faster the program runs (this is irony and the result is the exact oppos9te)
>>
>>109014773
because /g/ is about mindless sporst-like affections to languages, paradigms, operating systems, companies etc where what matters isn't discussion but "owning" the other side.
>>
>>109014831
That's not because of loops, it's the same with any other control flow, it's just because (assuming the data is the same size for each added loop) you are doing exponentially more iterations.

Where you need to start reconsidering the data structure is when you're iterating over the same data more than once, then there's perfectly sensible designs that pretty much require many, technically stacked loops.
>>
>>109014022
https://archives.loomcom.com/genera/genera-install.html

Bonus: https://interlisp.org/
>>
>>109007048
based looper
>>
>>109007594
iterators are lazy retard
(in serious languages, don't know about lisps)
>>
>>109011480
>dont think you will pull it off in the 4 or so lines the recursive version takes
and you will not pull it off at all because you will hit fucking stack overflow unless someone unrolls your stupid recursion into a loop under the hood
>>
>>109014628
pretty nice you get to keep your loop pass
>>
>>109011227
Beautiful.
>>
>>109014677
kek, someone always seems to take that shitpost seriously
>>
>>109014677
Due to C strings you need C++ to write real code.
>>
>>109018249
huh, explain
>>
>>109018303
anon has a retarded opinion, what is there to explain?
>>
>>109018414
>C strings are retarded so autist spams retarded to project on behalf of C.
>>
>>109016755
>stack overflow
the deficiencies of your system are not my problemo
>>
>>109018585
>deficiencies of your system
I'll start throwing this in alongside "that's the compiler'a job"
>>
>>109007216
>>Have to iterate through an array
Well if the problem demands iteration, you have to iterate.
But if the problem is actually "perform an operation on each item in an array and the order of operations doesn't matter" then specifying a sequential loop is probably a mistake.
>>
>>109020132
>then specifying a sequential loop is probably a mistake.
only if you are programming a gpu, you fucking idiot
>>
>>109020470
or anything where you might use multiple cores.
the cores don't even have to be on the same machine.
I'm not even anti-loop but you don't seem to know anything about programming.
>>
>>109011393
Do explain then, genius.
>>
>>109009925
>state found in state machine
duh
>>
>>109018585
your program needs to run on a finite state automaton not an ideal infinite turing machine. if it can't do that it's not a correct program.
>>
>>109009925
the kernel is state for a finite state automaton (your CPU and its memories)
>>
>>109007048
Are they safe loops though, will your daughter be safe if you use them?



[Advertise on 4chan]

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.