freenode/#lisp - IRC Chatlog
Search
10:47:08
Lycurgus
https://trac.common-lisp.net/bordeaux-threads/wiki/ApiDocumentation that's the documentation?
10:48:12
no-defun-allowed
Plenty of Lisp things come from Bordeaux, but that factoid is usually shadowed by the somewhat larger wine output.
10:48:48
MaiAtusmi
I wrote a code in prolog and I need to do the same in lisp but I can't understand the logic...
10:50:49
no-defun-allowed
Bordeaux is a town in France -- oh, yeah, that's that, but that's not the same as bordeaux-fft.
10:52:00
no-defun-allowed
"FFT" refers to the Fast Fourier Transform, which maps a sample into an approximation of its frequency components.
10:52:33
MaiAtusmi
The job is to create a regular expression controller to check if it's a regular expression
10:54:21
jmercouris
MaiAtusmi: I can continue to help you on this channel, it'll be much easier than the messages on Reddit
10:54:48
jmercouris
I'm sure someone knows how to use finite automata, yes, anyone with a CS degree should, and I believe most of us here do have one
10:56:01
jmercouris
I think the goal is to check if the regular expression is a valid and logical expression
10:56:42
jmercouris
I basically had said to the user that they should make a function called is-valid-transition or something like that with a list of acceptable state transitions and then iterate through all of the chars in the regex string checking to see if all transitions are valid
10:58:34
jmercouris
Lycurgus: that's the only documentation I've ever seen, there is also some stuff in the Lisp Cookbook
11:03:13
beach
MaiAtusmi: All that stuff is very well documented. I suggest you go read the relevant documents.
11:04:37
jmercouris
Also, I'm afraid that this is no longer really a Lisp question, so I can't help you, this is more of a core computer science concepts thing, which I don't think you understand. First you must understand the concepts before the implementation
11:11:12
no-defun-allowed
I think it's more of a CS theory problem than a Lisp problem until you start implementing it, but I don't know anything about DFA and regular expressions (bar cl-ppcre) so I can't say.
11:11:47
jmercouris
it comes from the kind of people who think ed is a good editor, and mastering awk is a fantastic idea
11:19:33
pjb
MaiAtusmi: basically, each node in the regexp parse tree corresponds to some subgraph of your final NFA/DFA. It's rather trivial to build it. Then you can use NFA/DFA theory to normalize and simplify it.
13:22:39
beach
So what I want to do with the FFT is to generate assembly code by executing a Common Lisp program. The optimal number of operations is obtained when the radix is √n for a problem of size n.
13:22:46
beach
But that is messy, because in order for good code to be generated, the radix must be a constant. So I was thinking of generating a special version of FFT for each power of 2, up to some limit, of course. Then the radix is known statically for each case.
13:22:52
beach
I also want to use special floating-point instructions that can do several operations in parallel, hence the assembly.
13:22:54
beach
If shuffling is required, I already have a publication with the world's fastest shuffle algorithm. :)
13:36:20
scymtym
and just as important: https://www.pvk.ca/Blog/LowLevel/napa-fft2-implementation-notes.html
15:09:22
minion
The URL https://gitlab.common-lisp.net/users/sign_in?secret=60ec7dbd will be valid until 15:15 UTC.
15:20:41
minion
The URL https://gitlab.common-lisp.net/users/sign_in?secret=edcbb93f will be valid until 15:30 UTC.
21:06:47
edgar-rft
not really clever code -> (read-from-string (concatenate 'string "(list " "1 20 30" ")"))
21:10:38
aeth
asdf_asdf_asdf: A string is a vector of characters, so it really *is* just a fancy way of saying something similar to #(#\1 #\Space #\2 #\0 #\Space #\3 #\0) which is why you get something like that in list form when you coerce it to a list
21:11:06
aeth
asdf_asdf_asdf: if you want something more robust, and your input is *only* integers, then use parse-integer in a loop
21:11:47
aeth
That will tell you that it could parse the integer up to position 3, and it parsed 123. Then you have to keep iterating.
21:13:15
aeth
If your input is something else, then you'll need something even fancier, and edgar-rft's hack solution looks better the more work you'd have to do
21:14:52
aeth
As an alternative to calling parse-integer with :junk-allowed, you could manually scan for the space separator and use parse-integer with :start and :end keyword arguments. If you use a more general parser from a library, you'd probably have to do this.
21:16:24
aeth
asdf_asdf_asdf: an example of this second form, which can easily be turned into a loop: (let ((string "7 20 30") (start 0)) (parse-integer string :start start :end (position #\Space string :start start))) => (values 7 1)
21:17:55
aeth
For something more general than an integer with parse-integer, you'll need another parser, ideally from a library, with the only requirement that it also needs to support :start and :end (any good one should). Alternatively, you can use something like cl-ppcre or split-sequence to split the string on #\Space instead of tracking the start position.
21:18:39
aeth
(And if it's just a throwaway script, there's nothing wrong with using edgar-rft's much simpler, but inelegant, solution)
21:27:35
aeth
Oh, I should also add that read-from-string is itself one such parser that takes a :start and a :end, so you could use the function edgar-rft used, but with my position-iterative or string-splitting approach instead of wrapping it in "(list " and ")", but it is probably too powerful for the given task.
21:35:46
akoana
aeth: would it be a good idea to (setf *read-eval* nil) before using read-from-string?
21:45:23
aeth
asdf_asdf_asdf: instead of using nth-value and calling it twice, you can use multiple-value-bind like this: (multiple-value-bind (number position) (parse-integer ...))
21:48:40
aeth
so you put the number you want to collect at the end, e.g. (multiple-value-bind (number position) (parse-integer ...) ... number)
22:05:21
fengshaun
how do I reset the symbols slime has loaded with slime-eval-buffer? I'm changing code and re-eval-ing, but now slime refuses to redefine my structs
22:07:15
aeth
asdf_asdf_asdf: I think that you can combine the do and the collect and get rid of the do, although you'll have to be careful that things are evaluated in the correct order
22:07:22
asdf_asdf_asdf
Is other manner to ignore argument from multiple-value-bind? I must use (declare (ignore arg))? How skip argument without (declare (ignore ...?
22:08:19
aeth
I think you can just get rid of the collect, replace the word "do" with "collect" and put j as your last line, and it should collect
22:08:47
aeth
(I'm not 100% sure without evaluating it because loops can often have ordering issues)
22:09:21
aeth
collect will collect the return value, so you don't really need both a do and a collect... you can have as complicated of a collect as you want
22:12:26
akoana
aeth: so this would be a safer variant of edgar-rft's proposal: https://termbin.com/ay89 - I've you care to have a look at :)
22:14:21
aeth
asdf_asdf_asdf: in case I was unclear, s/collect (parse-integer a :junk-allowed t :start junk1)// s/(declare (ignore j))// s/do/collect/ s/(setf junk1 n-v)/(setf junk1 n-v) j/ and it works (of course, you'd want better code formatting than that)
22:16:01
aeth
asdf_asdf_asdf: just replace "do" with "collect", you don't need an additional collect. collect will gladly do side effects like do, and the collect part only cares about the final value, which can be what you called j
22:16:17
aeth
then you don't need to ignore j, you can put j as the last position in the multiple-value-bind