Search
Sunday, 17th of June 2018, 22:26:24 UTC
22:29:55
refrijerator
(let ((line "set a 1")) (read-from-string (format nil "(~a)" line)))
22:30:18
refrijerator
is there a better way to read the line as a list of atoms?
22:30:44
refrijerator
than using (format nil "(~a)" line)
22:33:24
Bike
you could loop and read a string stream, but it's not much better
22:35:20
refrijerator
maybe this is a use for a read macro?
23:02:42
johnvonneumann
** NICK Guest39038
23:23:36
pillton
You could also use the position return value of read-from-string and its start argument.
2:03:02
mrottenkolber
** NICK Guest44929
3:03:06
on_ion
froggey: seen this? https://github.com/grz0zrg/fbg
3:58:46
aeth
What do people use for Lisp testing? I've seen two. Roswell. And now this lisp-devel Docker. https://lispcookbook.github.io/cl-cookbook/testing.html#gitlab-ci https://hub.docker.com/r/daewok/lisp-devel/
4:09:40
edgar-rft
aeth: there's an ANSI test suite for testing Lisp, but I assume that you're not looking what you're asking for.
4:29:40
aeth
edgar-rft: No, I mean testing Lisp code in the cloud
4:59:17
beach
Good morning everyone!
5:01:33
low_brain_cache
good morning
5:02:45
beach
low_brain_cache: Are you new here? I don't recognize your nick.
5:03:34
low_brain_cache
I haven't registered a nick but I've been on here as beginner_supreme, cl0s, Common_Lisp (I think), etc.
5:04:13
low_brain_cache
I like to read the conversations on here and learn.
5:06:37
low_brain_cache
I figure that since nicks are temporary assuming low activity, and registering a nick doesn't necessarily disallow others from using it, there's no reason to register
5:06:57
low_brain_cache
But I'm not knowledgable about IRC per say so..
5:07:48
beach
You do get a password when you register. I don't know how secure it is of course.
5:13:32
LdBeth
I believe freenode also allow to register several different nick under one mail address for bot or something
5:14:47
low_brain_cache
Is there a freenode manual of commands? /help lists a table but /help <command> doesn't do anything. <- Sorry for the non-lisp question but since we're on the topic of IRC... ;)
5:19:47
LdBeth
low_brain_cache: many commands are IRC client specific, so you should find your own manual
5:29:14
low_brain_cache
Have a good night everyone! Can't stay awake any longer
5:30:00
beach
'night low_brain_cache.
7:40:07
kuribas
Hi, I've set inferior-lisp-program with customize to sbcl, however everytime I restart emacs, it gets reset to lisp. Any idea why?
7:40:52
varjag
anyone here closely familiar with cl-async?
7:42:59
hajovonta
kuribas: I think this is an #emacs question, but I think you should set the state to "Save for future sessions"
7:43:27
kuribas
hajovonta: yes, I did that.
7:44:03
varjag
open your .emacs and see if it saved
7:44:27
kuribas
it's just not using it at startup
7:45:46
varjag
check with C-h-v what the variable is set to in the running instance
8:00:06
kuribas
well it was before, I set it to sbcl manually now.
8:15:36
kuribas
what's the equivalent of take-while (haskell) in common lisp?
8:15:59
kuribas
takeWhile :: (a -> Bool) -> [a] -> [a]
8:21:29
kuribas
but without mutation?
8:22:16
jdz
Is this what takeWhile does? (loop for x in list while x collect x)?
8:22:43
loke
jdz: I thought it was more like remove-if-not?
8:23:23
kuribas
takeWhile isDigit "134abc" => "134"
8:23:33
jdz
I have no idea. Defining questions in terms of what Haskell does in #lisp seems... wrong.
8:23:51
kuribas
takeWhile isDigit "134abc523" => "134"
8:24:36
jdz
(loop for x in list while (digit-char-p x) collect x)
8:25:14
jdz
Why do you want to do that with DOLIST?
8:25:21
kuribas
jdz: you suggested it?
8:25:29
jdz
Because I have no idea what you want.
8:25:43
kuribas
yeah, that loop looks right
8:26:46
jdz
(subseq sequence 0 (position-if-not #'digit-char-p sequence))
8:30:34
jdz
Lisp is not Haskell, so this most likely is not the best way to solve whatever problem it is you're solving.
8:31:13
jdz
(parse-integer "134abc523" :junk-allowed t)
8:33:00
kuribas
jdz: trimming whitespace
8:33:52
specbot
http://www.lispworks.com/reference/HyperSpec/Body/f_stg_tr.htm
8:34:41
jdz
ACTION wonders what's the Haskell for STRING-RIGHT-TRIM is...
8:35:17
kuribas
jdz: reverse . takeWhile isSpace . reverse
8:36:00
loke
kuribas: Wouldn't that swimplyimply return the last spaces?
8:36:24
kuribas
loke: ah right: reverse . dropWhile isSpace . reverse
8:37:11
jdz
Simple, beautiful, efficient. Choose 2.
8:37:27
loke
jdz: I think the haskell example is more like choose 0
8:37:52
jdz
This is #lisp, we can bash Haskell to our heart's content.
8:38:09
loke
No one will every convince me that reverse drop reverse is simple or beautiful. With a magic compiler is may be efficient. Maybe.
8:38:10
jdz
Except too much of it is off-topic.
8:38:26
jdz
Strings being lists does not help, eh?
8:38:48
jdz
Pretty sure they are in Haskell.
8:38:50
loke
I don't know more than the absolute basics of Haskell
8:39:04
loke
But... CATEGORY THEORY!
8:39:50
lieven
the standard prelude has some awkward stuff in it. for real work, you should use Text for strings
8:40:22
jdz
Right. And pattern matching works the same on Text?
8:40:37
lieven
kinda sorta not really :)
8:40:56
kuribas
jdz, loke for efficiency you'd use stripEnd on Text.
8:41:19
jdz
Looks like cheating to me.
8:41:45
jdz
Might as well write the whole thing in CL.
8:42:08
kuribas
jdz: the same amount of cheating as string-trim
8:42:49
jdz
Then why all the talk about takeWhile when what you should have asked is stripStart?
8:42:55
varjag
but in cl you are meant to cheat
8:43:04
varjag
all purists are over in #scheme
8:43:43
kuribas
I was reading this, and I found the lisp code quite ugly: https://markkarpov.com/post/lisp-and-haskell.html
8:43:58
kuribas
might not be the best implementation though...
8:45:14
kuribas
varjag: yeah scheme is great
8:45:30
varjag
some people should blog less and code more
8:45:49
jdz
Right, first example, the MAP 'string should be plain DOLIST.
8:46:19
jdz
Well, not DOLIST, LOOP. Or MAP nil.
8:47:38
kuribas
in haskell: addPadding str pad newline = intercalate ('\n' : replicate pad ' ') $ lines $ if newline then "\n" ++ str else str
8:48:11
kuribas
there's a CL version of lines here: https://github.com/vindarel/cl-str
8:49:08
hajovonta
Common Lisp is not a functional language, but it supports functional style programming.
8:49:08
varjag
i'm sure it's even more elegant in perl
8:50:32
loke
kuribas: Thtat link you sent
8:50:43
loke
not only is it ugly Lisp. It's wrong and broken.
8:50:52
jdz
I wonder why people who have no real experience with a programming language immediately have an urge to write articles titled "Why XXX is not my favourite programming language and why you should use YYY."?
8:51:54
varjag
jdz: noone knows programming better than a fresh graduate
8:52:22
kuribas
how would you write add-text-padding?
8:52:54
hajovonta
"if your code compiles, it probably works" lol
8:52:56
loke
kuribas: I'm not entirely sure what that function is supposed to do
8:53:09
shrdlu68
kuribas: Are you the author of that blof post?
8:53:11
loke
kuribas: Tell me what you want it to do and I'll tell you how to write it
8:53:37
shrdlu68
It's fizzbuzz time!
8:53:38
kuribas
loke: prepend pad amount of spaces to each line except the first.
8:53:42
hajovonta
loke I think (judging by the name) it takes a string and extends it with dummy characters or something like that
8:53:46
loke
shrdlu68: Did you see the add-text-padding fuction? Wtf... w-o-t-s with a map 'string inside followed by a return that is never used?
8:54:35
kuribas
loke: I don't care about the newline argument
8:54:41
loke
Oh wait. he maps over the characters. And he seems to believe that 'string refers to the type of the thing he's mapping over
8:54:48
jdz
kuribas: what is the ADD-TEXT-PADDING supposed to do?
8:55:09
kuribas
jdz: see my comment for loke
8:55:09
jdz
Add padding at the start of a line?
8:55:17
loke
kuribas: so you want to add spaces to make every line the same length?
8:55:32
loke
jdz: it seems to add it to the end
8:55:32
jdz
Why is the first line special?
8:56:20
kuribas
jdz: it's not my blog
8:56:29
loke
So it just adds PADDING number of chars to the beginnign of each line
8:57:03
loke
So he's just replacing #\Newline with <space...>#\Newline
8:57:15
varjag
replace newline with newline + padding
8:57:25
shrdlu68
So if new-line is nil it will return one line?
8:58:20
loke
ACTION would probably just use CL-PPCRE:REGEX-REPLACE-ALL
9:01:23
loke
He claims he wrote unix-opts
9:01:27
loke
I actually use that one
9:01:35
jdz
Never mind that the original code has parameter named STR that is shadowed by LET binding.
9:02:54
kuribas
how do you prepend newline in a string?
9:03:09
jdz
OK, that's intended. Making a copy of input for no apparent reason. I wonder if the guy has tested his code?
9:03:11
loke
I like his argument that QL doesn't use tests. But tests are required. Therefore QL is broken.
9:03:27
loke
Instead of: QL doesn't need tests, and still works. Perhaps I'm wrong and tests are not the end-all-be-all?
9:03:54
jdz
This function seems so convoluted it triggers all the possible wrong signals in my brain.
9:04:19
loke
jdz: It probably _has_ tests, and therefore it's perfect. No matter hopw convoluted. The tests pass!
9:04:55
kuribas
ok, so I have this, with the cl-string library: (join ((concat (string #\Newline) (repeat padding " "))) (lines str))
9:05:03
kuribas
That actually looks like the haskell.
9:05:55
kuribas
loke: regular expressions are messy.
9:07:29
jdz
If I had to work with lines I'd probably have a function MAP-LINES or something.
9:08:27
jdz
Which would call a supplied function with 3 arguments: STRING, START and END.
9:10:21
kuribas
that's less general
9:11:13
jdz
It would also not be dog slow.
9:11:31
kuribas
jdz: so show your version?
9:12:04
jdz
It's a stupid function with convoluted requirements.
9:12:40
jdz
I have real trouble wrapping my head around what it's supposed to do and in what circumstances one would use such a function.
9:12:53
jdz
If only the author of the blog post had some test cases...
9:13:05
kuribas
jdz: as I said before "prepend pad amount of spaces to each line except the first."
9:13:32
kuribas
jdz: ok fine, you just want to criticise...
9:13:54
varjag
https://pastebin.com/rDG3QEq2
9:13:57
varjag
something like that?
9:14:16
varjag
would still rather use a library function
9:16:04
kuribas
varjag: what do those parenthesis across the newline do?
9:16:42
jdz
kuribas: https://lpaste.net/6235782593799782400
9:18:41
kuribas
jdz: ok thanks. I don't find it more elegant, but "de gustibus..."
9:19:02
varjag
mine is elegant and inefficient
9:19:12
varjag
which i believe is closest to haskell spirit
9:19:25
kuribas
varjag: haskell is pretty efficient, after inlining etc...
9:19:35
kuribas
varjag: if you use Text, not String
9:20:11
jdz
Elegance is subjective. I personally find my version straight-forward and directly matching the problem statement, and also not particularly inefficient.
9:21:20
jdz
It is also very easy to change.
9:21:51
kuribas
also about 4 times the size...
9:22:38
kuribas
anyway, no point in discussing taste...
9:22:52
kuribas
I just wanted to know what is the idiomatic lisp solution.
9:23:42
jdz
Definitely not what's in the mentioned blog post.
9:25:37
varjag
kuribas: idiomatic lisp solution is to use an existing library, implementing this efficiently
9:25:55
varjag
cl-ppcre is a good start
9:26:53
loke
varjag: What is the purpose of the MAKE-STRING?
9:27:04
loke
Instead of that, couldn't you just do (STRING E)
9:30:59
jdz
I don't think deliberately inefficient code is elegant, either.
9:31:22
jdz
http://prog21.dadgum.com/116.html
9:31:57
shrdlu68
kuribas: https://gist.github.com/shrdlu68/beeed6385d9a323eebfdee5437c41dd8
9:31:59
varjag
it's not deliverately inefficient, i could do it a lot worse if i wanted
9:34:35
shrdlu68
A fiendishly clever person could probably do all this in one format string.
9:35:25
varjag
not entirely unlikely..
9:41:41
kuribas
shrdlu68: ok, so lisp programmers favour mutable solutions.
9:42:04
jdz
kuribas: my version was not mutable at all.
9:42:25
jdz
For any definition of "mutable".
9:42:38
kuribas
jdz: yes write-string and write-char mutate a stream.
9:42:58
jdz
kuribas: what stream? how can you observe that?
9:43:31
shrdlu68
jdz: He's referring to with-output-to-string.
9:43:43
jdz
Also, my version is easy to change so that it writes straight to a stream, without accumulating all the strings which most likely go to a stream afterwards, anyway.
9:44:08
jdz
kuribas: I recently heard that in Haskell it's also OK to mutate things if they don't escape a function?
9:44:33
kuribas
jdz: the type system makes sure it's still pure.
9:44:44
shrdlu68
kuribas: Well, then by that definition...
9:44:45
varjag
my version doesn't mutate anything either
9:44:47
jdz
I assert that it's pure.
9:45:25
kuribas
jdz: or you can use unsafe... functions, and assert it yourself.
9:45:31
jdz
Simple, pure and efficient! All 3.
9:45:31
shrdlu68
Called with exactly the same set of arguments, the result with always be the same, regardless of any changes outside the function.
9:45:56
shrdlu68
That, I thought, was the whole point of immutability.
9:46:26
shrdlu68
There is no way to alter the function's behavior outside of it.
9:46:50
jdz
shrdlu68: No, bragging about one's favourite compiler is the whole point of immutability.
9:47:21
varjag
just call your stream monad-stream and you're good
9:47:45
shka
why you are discussing haskell
9:47:50
shka
this is common lisp channel
9:48:12
jdz
ACTION guilty as charged
9:49:34
jdz
I was just hoping that making fun of Haskell would be a bit less off-topic.
9:50:01
hajovonta
safe functions are for pussies
9:50:32
jdz
Right, I also take scissors with me when I go jogging.
9:53:37
kuribas
real programmers directly write machine code
9:55:37
kuribas
is mapcar the same as map 'list ?
9:55:52
kuribas
just a specialised version of map?
9:56:29
jdz
kuribas: MAP works on sequences, not just lists.
10:02:19
LdBeth
shka: monads are not Haskell specific thing. Any languages with proper lambda support can have that
10:05:23
LdBeth
ACTION sorry I didn’t read log longer
10:08:04
LdBeth
A CLOS question, now I have a class which has slots shared across all instances by :allocation :class, but how can I access these slots given I only have name of that class with no instance
10:08:39
shka
LdBeth: find-class will return instance of class
10:09:29
shka
not sure where exactly value is, but i would start by checking slot definitions
10:09:37
shka
that are in the class object
10:09:46
shka
that you can inspect with slime inspector
10:10:59
LdBeth
Thanks, now I have some idea to start work with
10:20:24
flip214
Can anybody remember seeing a high-level interface to the Ethereum Blockchain RPC in CL?
Monday, 18th of June 2018, 10:26:24 UTC