Fork me on GitHub
#clojure
<
2022-07-23
>
pinkfrog13:07:40

How can I quote “127.0.0.1” for use in regex? The value “127.0.0.1" is generated dynamically and not from literal, so I cannot do something like #“127\.0\.0\.1” but instead I shall go with (re-pattern (quote some-var))

p-himik14:07:56

(java.util.regex.Pattern/quote "127.0.0.1") should work. Wrapped in re-pattern, of course.

Carlo17:07:36

@mauricio.szabo and generally spock question: how do I import a library, for example clpb in the current swi version of the library?

Carlo17:07:23

in prolog, I would do :- use_module(library(clpb))

Carlo17:07:02

also, I'd love a spock slack channel, so that these lessons are not lost!

Carlo18:07:47

Also, just a way to send raw prolog would be enough for this issue!

mauricio.szabo18:07:53

Ok, created the channel #spock

mauricio.szabo18:07:48

About that, I believe you can run (spock/solve '(:- (use_module (library clbp))))

mauricio.szabo18:07:18

But I don't know, Spock is honestly on its very beginning, so if this don't work I'll look at it 🙂

Carlo11:07:14

Ok, sorry for the delay, the suggested snippet doesn't work, because:

No implementation of method: :to-prolog of protocol: #'spock.swi/AsProlog
   found for class: nil

Carlo11:07:09

which is somewhat surprising

Carlo12:07:00

Ah, I think I get why this fails: :- is interpreted as the head of the compound form by as-struct. That is not what should be happening. In a directive, like :- use_module(library(clpb)) there is no head. Let me see if I can create the right object for this.

Carlo13:07:50

Ok, found it, you can actually do (spock/solve '(use_module (library clpb)))

Carlo13:07:47

In fact, sifting through the documentation, I saw that JPL actually doesn't have the concept of directive. They just re-use the same machinery as they use for queries.