freenode/#lisp - IRC Chatlog
Search
11:31:56
luis
aeth: LOOP is useful for many things besides collect. Parallel iteration, for instance. Also, iterating over sequences. And of course, it shines when you want to do all of those things at once.
11:35:29
luis
ck_: you can probably hack slime to make it always show the macroexpansion of loop inline using macrostep-expand. That way you could see the true way at all times.
11:36:12
jackdaniel
luis: is it possible to make slime inline macroexpand things put under macrolet?
11:46:49
luis
jackdaniel: looking at swank-macrostep::enclose-form-in-context, it looks like the mechanism can sometimes fail, so you might have come across one of those scenarios. Also, it doesn't work for slime-expand-1 (C-c RET)
11:48:36
ck_
luis: there's slime-trace-dialog-autofollow-mode, which was maybe originally intended to do something like we discussed (?), but it is acting pretty weird when I set it. Do you have any experience with that?
11:56:03
ck_
depending on [mysteries of the universe], it opens the inspector on the thing below the point
12:45:01
jdz
Because you're probably reading the line from a stream, and the stream should not be always open, and you should be using WITH-OPEN-FILE (or at least WITH-OPEN-STREAM).
12:47:41
jdz
But you probably don't want to push single-element lists, just (push (read-line ...) *user-input*).
12:48:08
no-defun-allowed
FIlystyn: have you written any other Lisp? That's not valid Lisp syntax, nor does it look very nice.
12:49:17
no-defun-allowed
Right, that's better. Now, you can remove the spaces between parens and names.
12:50:32
no-defun-allowed
Yeah, you should never have any space between names and their closest parens basically.
12:51:12
no-defun-allowed
And you will probably get better responses on #clschool, even if there's less participants.
13:11:25
pfdietz
A problem that LOOP or ITERATE (or any complex macro) should address: how can code walkers descend into this without expanding the macro?
13:14:22
pfdietz
The general problem is: do something to all the forms in a piece of program text. So, how do you find all those forms?
13:16:00
pfdietz
The old example I keep looking at is Waters' COVER package. It adds coverage annotations at all the branch points in code (inside a DEFUN or whatever).
13:16:22
pfdietz
And it has to cheat a bit to do that. And as a result, it doesn't work with code that uses ITERATE.
13:17:56
Bike
shivers's loop involves some kind of "low level" macros; skimmed the paper, don't really get it, still has something called syntax-rules
13:18:05
chris4197
I am really liking lisp so far. Even though I just know the basics of the basics so far.
13:29:30
jackdaniel
if you like melding with CL implementations I can suggest ECL, if you like clos-ology I can suggest McCLIM (I'm working on both projects so I will be able to help)
13:29:56
jackdaniel
if you look for some other bits and pieces you may look at projects at sharplispers group on github and try to fix issues in them
14:21:33
pfdietz
chris4107: there are json and xml parsers in CL already. Best to just use an existing one. If you feel the need to hack on one, improving test suites is always welcome.
14:28:22
Xach
I think it would be easier than xml but not as easy as json processing, and also when you're done you'd have something useful
14:29:23
Xach
cl-ppcre source code is also very interesting to read and worth studying to learn CL features
14:32:45
Xach
jdz: i would use it to decide how to process network data without first converting it to strings, which is costly in both time and space on my favorite CL (sbcl)
14:33:46
Xach
but if the data is utf-8 or ascii or whatever, being able to find interesting subsequences and doing targeted conversion would be handy
14:35:50
Xach
Here's the thinking. Converting 100mb to strings to search for the string "foobar" is more wasteful than converting the string "foobar" to octets and searching without conversion.
14:37:12
Xach
This comes up when parsing binary data in structured formats, whether on disk or over the network or whatever.
14:37:46
jdz
Xach: In my case I'm also looking for interesting bits in binary blobs, but then sometimes the blobs are UTF-16 encoded strings, and such thing would not help much, so I'm always converting.
14:39:11
jdz
Well, every other octet is 0. If I was looking for a specific string, then yes. But I'm looking for patterns.
14:40:21
jdz
Xach: Yes. I understand that such patterns can be translated from string into binary form.
14:44:25
Xach
Oh, and it's incomplete to say it only comes up in binary contexts. A text file is a binary file on disk. Writing grep with cl-ppcre loses because the conversion is expensive. If you matched without converting it would lose less.
14:45:03
jdz
I still have not proved to myself that this change https://github.com/jdz/cl-ppcre/commit/89d89c8477841d83ff7d83b26cdf51aaea9ce76e should be merged upstream, but it works for me.
14:45:41
jdz
But then, I think that not confusing octets with characters is a really great feature of CL (just look at all the Python2 vs. Python3 mess0.
14:47:43
Xach
chris4197: cl-ppcre is a really fun read and shows a cool way to handle stuff like that.
18:51:26
Bike
you mean like a local recursive function? because if it's globally defined you can just treat a recursive call like any other call to a global function
18:53:10
Bike
you can implement letrec as basically binding the variables to some kind of unbound marker, evaluating the forms in that environment, then modifying the environment to have the values of the forms for those variables.
18:54:50
chris4197
THAT was the video I thought of. Sadly it is in clojure. https://www.youtube.com/watch?v=2wPS_6oSD6k
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."