freenode/#lisp - IRC Chatlog
Search
21:25:32
hello80493485039
trying to implement a function similar to "positions" that takes in a number N and a list L and returns all the indices of N in L
21:26:09
Bike
hello80493485039: append does not have side effects like you seem to think, and it works with lists generally. maybe you want push.
21:29:12
hello80493485039
whhat is the lisp way of finding the indices of all N in a list e.g. suppose n = 2, list = (2 3 1 4 2) then result = (0 4)
21:29:52
Bike
there are innumerable ways to write it yourself, of course. your code seems like it will be reasonable once it's fixed up
21:30:20
Bike
i personally would do (loop for i from 0 for element in list when (eql element to-find) collect i)
21:30:43
dialectic
(loop for item in list for i from 0 when ... grrr ok bike, steal all the thunder.
21:31:54
Bike
with tail recursion it adds up to about the same, except of course yours collects backwards
21:33:49
Fare
asdf_asdf_asdf, use uiop to exit with a code, or run-program to run a program and check its exit code.
21:39:56
hello80493485039
Bike what do u think about this? https://gist.github.com/aamirsahmad/c9af6e26e166ece00f23d946d66b3670
21:43:45
Bike
list indices start at 0, not 1. using = means the list can only have numbers. using nth each iteration is less efficient than iterating over the elements simultaneously.
22:02:14
dialectic
Also my recursive version never terminates because I forgot to take the cdr of the list. Loop spoiled me.
22:04:55
dialectic
The only thing I ever use tail recursion for is statemachines, and even then, 90% of the state machines I have ever written are TAGBODY and GO
22:09:41
dialectic
Using recursion is a pedagogical thing. It is somewhat instructive, maybe even enlightening, but a real language for looping is much better for real use.
22:27:25
markasoftware
i'm not sure about that, i tend to find that as a loop gets more complex, it actually gets easier to implement with recursion and more difficult to keep as a loop
22:46:31
edgar-rft
Stupidly I can't remember where i read the following sentence: "Loop was designed to provide simple solutions for simple problems. As soon as things become more complex it's most often easier to implement solution in more complex code."
23:45:27
seok
Thanks Bike and PJB I fixed the code, works with a function I had missed a parantheses
23:55:39
no-defun-allowed
random-nick: (remove-if-not #'listen streams) -> streams-ready-to-be-read-from
4:40:54
dannyboy35
Hi I’m new to lisp and was wondering what development environment would be suggested? Please don’t say slime lol
4:44:10
bmansurov
o/ Can anyone tell me how I can return from a recursive call? Line 8 here: https://pastebin.com/udgjP4em . (return-from helper (car l)) doesn't seem to do the trick.
4:45:25
dannyboy35
LdBeth: I’ve been teaching myself python but haven’t really done anything with it
4:47:00
dannyboy35
I know a bit of C I took s Visual Basic class in college so I’m not new to programming but I wouldn’t call myself a programmer
4:47:18
LdBeth
<dannyboy35 "LdBeth: I’ve been teaching mysel"> dannyboy35: then the first thing I’d like to recommend is to get some feeling of doing programming, and I think the most productive way to do so is learning emacs : D
4:53:40
LdBeth
dannyboy35: You don’t have to learn and read a lot to use it, my recommendation is http://spacemacs.org/ which is a work out of the box config for many programming languages including C python CommonLisp Scheme Haskell Swift ...
4:57:47
dannyboy35
I have played with emacs in the past vim is just a lot easier to use at least for me
5:03:51
dannyboy35
Well LdBeth I’m going to sleep it’s 1 am here and I work tomorrow afternoon I’ll definitely be back my nick on my computer is danielboston26 I’m on my iPhone right now
5:05:48
bmansurov
beach: ok thanks, is there a way to return from the recursive call but stay inside the main function?
5:07:00
LdBeth
bmansurov: you decide which function to return to by passing the function name to return-from
5:11:26
bmansurov
beach: sure, I think length and nth solves it easily, I wanted to try the recursive version.
5:13:30
beach
Your Common Lisp system may have a very small stack, so the risk of too great a recursion depth is significant.
5:49:17
beach
jeosol: Are you excluding the women here, or are you using "guys" to refer to women as well?
5:50:47
jeosol
pardon. I used it loosely to refer to both gender, I guess, just "good morning" is correct
5:52:46
jeosol
been a while since i was here, but noticed webchat.freenode.net has a much nicer interface now
5:55:34
jeosol
I was trying to get a case-based reasoning book with lisp on Amazon, recalling seeing one with lisp code
5:59:25
jeosol
that's great. It's the general area. I am looking at implementing some standard problems from some articles with Gabor's/ or any neural network code and compile the examples. Some of the code examples are in python and wanted to have a compilation of these examples
6:00:18
jeosol
aindilis: what areas of AI are you working on? Are you currently using any specific libraries?
6:01:35
beach
jeosol: If you go to Tymoon, you can search for aindilis and get the contents of the conversation.
6:09:06
no-defun-allowed
I think what dmiles has is written in Java though, but the database is in s-expression format.
6:11:33
jeosol
ok. not very Java saavy, tried picking it up for some stuff a while ago, and lost my mind -- very verbose then
6:13:13
jeosol
I am planning to get some books on AI books with some CL focus. I am interested in cognitive systems and explainable AI
7:37:49
LdBeth
ck_: I’m more interested in the interaction interface rather than the logic framework beneath