freenode/#lisp - IRC Chatlog
Search
18:34:32
dim
and rather than CLON I wrote my own simple stuff for parsing commands and subcommands ala git, but didn't separate it out from some of my stuff
18:35:13
dim
https://github.com/dimitri/pgcharts/blob/master/src/utils/cli-parser.lisp is used in https://github.com/dimitri/pgcharts/blob/master/src/pgcharts.lisp if you're curious
18:59:01
emaczen
How do we distinguish between C function names and lisp names with defcfun? For example, open and write?
18:59:39
Colleen
Macro defcfun https://common-lisp.net/project/cffi/manual/cffi-manual.html#defcfun-1
19:25:27
emaczen
how do you specify a union type in cffi:foreign-slot-value of cffi:with-foreign-slots?
19:31:18
jackdaniel
(usually I find libraries with no documentations, readmes or half-finished ones)
19:31:32
Bike
if you tell it "this thing is either an int or a char*" that doesn't really give cffi anything to work with
19:31:51
emaczen
Bike: Ok, so in the C code it object.union.field.field in lisp it would be (slot (slot object))
19:32:31
Bike
cffi is kind of apathetic about a lot of C stuff. it just takes memory and goes "that's a float? you got it, boss, float coming right up"
19:34:47
emaczen
Bike: CFFI is pretty good, I like that approach. I only wish it was a bit more steamlined to find out the constants I need for me -- I don't want to mess around with the groveller
19:35:50
emaczen
I wrote a macro that writes a c program that prints out the info I want in a plist, and then I compile it, run it and read it.
19:37:31
emaczen
Bike: Oh, well I spent more time a few months ago looking at the groveller than an hour getting this to work
20:10:44
jasom
if you're willing to wait a couple of GB should be enough for it to make forward progress
22:38:13
xsperry
hi. what would be the closest equivalent of list comprehensions in lisp? loop macro?
22:39:04
xsperry
particularly in cases when you iterate over two or more lists. do I need nested loops for that?
22:45:37
edgar-rft
a) what are "list comprehensions"? b) It's possible to iterate over several lists at once with the same pros and cons as in other languages. Nested loops are the simplest possibility.
22:46:45
Bike
list comprehensions are a syntactic construct in python and other languages that is indeed kind of like loop.
22:51:17
xsperry
ok, here's a simple example that is very easy to express with list comprehensions. given two lists, '(1 2 3) and '(4 5 6), make a list of conses consisting of each element from list A and list B. so '((1 . 4) (1 . 5) (1 . 6) (2 . 4) (2 . 5) (2 . 6) (3 . 4) (3 . 5) (3 . 6))
22:53:17
jasom
xsperry: I believe that's a nested loop in python as well (unless you use itertools which has that function builtin IIRC)
22:53:35
Bike
it would have to be a nested loop under the hood since you're iterating over both lists independently, anyway.
22:55:14
xsperry
jasom I think you don't, but I am not 100% sure. it has been years since I used python, but python's list comprehensions were inspired by haskell's, and in haskell you don't need to nest list comprehensions for this
22:55:47
xsperry
I am actually trying to replicate this really elegant example from haskell tutorial in CL
22:57:07
jasom
as in (loop for x in xs for y in ys collect (cons x y)) would return just 3 items with your inputs.
22:57:10
xsperry
jasom, you would zip lists first, and then then pattern match on resulting list. but at that point you probably wouldn't be using list comprehension
22:57:41
shachaf
Oh, LOOP iterates through lists together instead of nesting? That's what I get for saying something in here.
22:58:23
shachaf
In GHC Haskell you can write [(x,y) | x <- xs, y <- ys] for nesting and [(x,y) | x <- xs | y <- ys] for zipping. But zipping seems to me like a much more unusual behavior.
22:58:25
xsperry
this is the example I'm trying to rewrite in CL. it takes first 10 right triangle that has integers for all sides
22:58:40
xsperry
[(3,4,5),(6,8,10),(5,12,13),(9,12,15),(8,15,17),(12,16,20),(15,20,25),(7,24,25),(10,24,26),(20,21,29)]
22:59:22
xsperry
[1..] would probably be hard to emulate, but what about the rest? three nested loops? what are the alternatives?
23:02:00
jasom
xsperry: I'm not sure how the haskell example works; does it find all right triangles where the first side is of length "1" first?
23:03:10
xsperry
jasom, [1..] is an infinite list of integers. take 10 drivers computation, and since haskell is lazy it will only compute enough to take first 10 such triangles
23:06:27
jasom
it is indeed lazy which is <sarcasm>completely obvious from the source to anybody</sarcasm> https://github.com/jasom/itertools/blob/master/itertools.lisp#L406
23:07:13
aeth_
Well, that was an incredible mess. nickserv and chanserv were down but nearly every channel was +r and in every other one you couldn't speak. So if your Internet went down in a period of about 4-5 hours or you tried to connect, you were out of luck, apparently.
23:09:22
aeth_
And the best part is, when it forced my nick to Guest1234 or whatever when nickserv came back, it made my nick temporarily unavailable.
23:10:32
xsperry
jasom, ok, this is a lot more similar to the solution above than I imagined it to be. if I got it right, can I use loop to generate some lazy equivalent of a list (infinite list of right triangles), and then take first 10 such elements?
23:10:35
shachaf
As I'm trying to figure out some language ideas the language is becoming more and more like lisp. I guess this is an old story.
0:00:40
xsperry
_death, interesting, thanks. I wonder how close we can take it syntax wise with macros
0:11:05
_death
I guess something like this isn't too bad (take 10 (gen ((c (range 1)) (b (range 1 c)) (a (range 1 b))) (when (= (square c) (+ (square a) (square b))) (list a b c))))
3:38:15
krwq
how does slime figure out the arguments for macro/function? I tried to use function-lambda-expression but it seems it does something more clever
5:10:20
earl-ducaine
Use of the question mark (rather than -p) seems barbaric: https://gist.github.com/earl-ducaine/dd90263f81d44ab1de90c868bff86c1f
5:18:39
sabrac
earl-ducaine: https://www.cliki.net/naming%20conventions indicates that scheme uses the question mark.
5:35:47
sabrac
https://google.github.io/styleguide/lispguide.xml#Predicate_names notes some existing CL packages use ? but recommends against it
5:40:10
earl-ducaine
The code in question was written by Mlynarik (mly), who was working at Xerox at the time. So, it might have been a Interlisp convention.
6:01:39
aeth
The two main styles are either p for single words and -p for multiple words or -p for everything. -p for everything does have its users
6:07:06
aeth
The original style is foop and foo-bar-p. foo-p came later, either to make it unambiguous or because someone misunderstood the rules (probably both, depending on the person)