Skip to main content
Filter by
Sorted by
Tagged with
1 vote
0 answers
103 views

I am interested in expressing the number of occurrences of an element in a list as a relational goal in Clojure's core.logic library. (Note that this question is not a duplicate of clojure core.logic ...
oper0's user avatar
  • 11
0 votes
1 answer
78 views

I have written a Clojure program to solve a fairly simple problem. Consider a vector of a fixed size that we need to fill with integers. We must abide by the following rules. Every integer must be ...
mmachenry's user avatar
  • 1,992
2 votes
2 answers
83 views

Why the first expression (involving maps) doesn't yield any solutions, whereas the second one (involving vectors) does? (run* [a b] (== {:a b} {a :b})) ;> () but (run* [a b] (== [:a b] [a :b])) ;...
Computerphile's user avatar
1 vote
2 answers
181 views

(def dbSample { :person [{:person/id 1 :name "dan" :surname "stone" :joindate "01.06.2022" :experience :experience/starter :loyalitylevel :...
Barış Can Ateş's user avatar
0 votes
3 answers
147 views

Suppose I have a simple string that I want to parse into array of string: "add (multiply (add 1 2) (add 3 4)) (add 5 6)" How do I parse it into 3 strings (based on outer parentheses): add (...
Kevin Tanudjaja's user avatar
1 vote
0 answers
143 views

Prolog mixes logic (fallible) goals, and (infallible) processes like write/2 or assert/1. Is it possible to do so with Clojure's core.logic? For example: (pldb/with-db myFacts (l/run* [x y] ...
Hugolin Bergier's user avatar
1 vote
1 answer
307 views

I have started learning clojure and have one use case where I would want to call a downstream service with query-params. Now these query-params can vary and can be absent. I am stuck at how to ...
Yash Jain's user avatar
  • 315
3 votes
1 answer
216 views

I'm learning relational programming in miniKanren and I decided to implement a time scheduling system. Basically, it boils down to three relations over finite domain. First, there is a time strip that ...
tsuki's user avatar
  • 907
1 vote
1 answer
77 views

I want to put fresh lvars with a finite domain into a map, and establish a relationship between them in another part of my code. Consider the snippet below: (l/run 1 [q] (l/fresh [x y z a b c] ...
tsuki's user avatar
  • 907
1 vote
1 answer
113 views

Consider this blog post where the author implements palindrome relation using reverso: (defn reverso [l r] (conde [(== l ()) (== r ())] [(fresh [la ld ldr] (conso la ld l) (...
tsuki's user avatar
  • 907
2 votes
1 answer
360 views

I am making a simple API That will require to read body parameters from a json/edn request I am trying to get the program to echo the contents as edn objects but something seems to not work here is my ...
Pouriyatajmehrabi's user avatar
1 vote
0 answers
31 views

I have code block in java where I am trying to add customCodecProvider for mongo (use 'clojure.reflect 'clojure.pprint) (pprint (reflect org.bson.codecs.configuration.CodecRegistries)) { :bases #{...
arjunsv3691's user avatar
1 vote
0 answers
86 views

I have been using ubergraph last few weeks up until this morning, but now am having compiling problem. In my project.clj's dependencies, ubergraph is declared: (defproject graph-alg "0.1.0-...
freebirds's user avatar
2 votes
2 answers
1k views

Task is to write a program that can decide whether two words are synonyms or not. I have pairs of synonymous words, E.g.: [big large] [large huge] [small little] We can derive the synonymous ...
Sharas's user avatar
  • 915
1 vote
0 answers
97 views

As CLP(set) seems to be stuck in the "immediate" roadmap for now 7 years and counting, I'm trying to make an incomplete, inefficient substitute to at least be able to reflect the semantics ...
AticusFinch's user avatar
  • 2,441
1 vote
1 answer
140 views

I'm currently working on a problem that asks to look for certain vendors that can fulfill an order. The vendors are represented as maps, as is the order. A vendor can fulfill an order if it can serve ...
Derek Taylor's user avatar
1 vote
1 answer
243 views

We are using a forward-chaining rule system where we have to spoon-feed the system the data it needs to make a decision. I'd prefer the rule system can ask the questions to obtain the data needed for ...
Joel's user avatar
  • 2,698
4 votes
1 answer
927 views

I have been playing around with miniKanren, trying to understand it by converting very basic Prolog tutorials into it. I use Python habitually so I started with the LogPy library, which has since been ...
Anentropic's user avatar
  • 34.2k
1 vote
1 answer
398 views

I'm looking for an idiomatic constraint satisfaction solver that can maximize or minimize a goal function, rather than producing a list of matching solutions. To be precise, I'm more interested in ...
vanhemt's user avatar
  • 165
0 votes
1 answer
65 views

I am trying to model a graph using core.logic and would like to match all nodes that have edges to two other nodes. I have come up with the below but it returns two results instead of the desired one, ...
mac's user avatar
  • 10.1k
3 votes
1 answer
865 views

I've been playing with Prolog recently and getting my head around how to represent some tasks I want to do with it, which are largely about having a database of facts and doing simple queries on it, ...
interstar's user avatar
  • 27.5k
0 votes
1 answer
73 views

So here is my problem, I have a file sample.clj in namespace abc.xyzin which i am calling db init method directly before doing any CRUD operation. (db/init some-config) When i require this ...
KshiTij SiNgh's user avatar
2 votes
3 answers
377 views

I am a newbie in Clojure.The problem originated when I once checked the source code of conj: (def conj (fn ^:static conj ([] []) ([coll] coll) ([coll x] (clojure....
两极化's user avatar
  • 143
0 votes
1 answer
74 views

Is there a way to prefer certain paths over others during solving? This is really a performance question. When I put all my logic together, it generates 1000’s of solution and this takes exponentially ...
Marc's user avatar
  • 823
0 votes
2 answers
235 views

How do I get the exact answer instead of just the number / count I can get the average of a list of numbers, but it will only add the total numbers and divide by the count (defn aver [numbers] ...
Ryan Jackson's user avatar
0 votes
1 answer
97 views

I'm trying to rewrite the below piece of core.logic code. (run* [x y] (fd/in x (fd/domain 1 2)) (fd/in y (fd/domain 1 2))) o/p, ([1 1] [2 1] [1 2] [2 2]) I tried the below versions but none ...
Kannan Ramamoorthy's user avatar
2 votes
1 answer
136 views

In core.logic of function, I see the below definition for clojure.core.logic/everyg. A pseudo-relation that takes a coll and ensures that the goal g succeeds on every element of the collection. ...
Kannan Ramamoorthy's user avatar
3 votes
1 answer
117 views

I was trying to understand a custom core.logic constraint as defined below, (defne lefto "x appears to the left of y in collection l." [x y l] ([_ _ [x . tail]] (membero y tail)) ([_ _ [_ . ...
Kannan Ramamoorthy's user avatar
-1 votes
2 answers
968 views

I'm using Mac OS. I want to execute a system command using (use '[clojure.java.shell :only [sh]]), like in How to execute system commands?. I have read https://clojuredocs.org/clojure.java.shell/sh ...
Vikram Shaw's user avatar
4 votes
1 answer
297 views

(ns verbal-arithmetic (:require [clojure.core.logic :refer [all run* everyg lvar == membero fresh conde succeed fail conso resto]] [clojure.core.logic.fd :as fd])) (comment "Solving ...
Clojurevangelist's user avatar
3 votes
1 answer
299 views

I'm trying to get to grips with core.logic. Can I use complex data-structures in facts and rules? For example, I'm trying to do this : (pldb/db-rel test a) (defn is-wibble? [a] (= true (:wibble a)...
interstar's user avatar
  • 27.5k
1 vote
1 answer
117 views

In core.logic, is there a way to translate the outputs of a program like (run 2 [q] (fresh [a] (featurec q {:foo a}) (membero a '(5)) (conde ((featurec q {:bar 2})) ((...
Alex Lew's user avatar
  • 2,134
0 votes
2 answers
205 views

I am new to clojure, my function elligble voters is not returning the vector, where am i going wrong. (def human-db [ {:name "Kanishk" :age 28 :sex "male"} {:name "Kanishk1" :age 29 :sex "...
user2114063's user avatar
0 votes
1 answer
295 views

I am trying to implement a solution for minimum-swaps required to sort an array in clojure. The code works, but takes about a second to solve for the 7 element vector, which is very poor compared to ...
zooes's user avatar
  • 1,518
3 votes
1 answer
155 views

I'm interested in the "use the right tool for the job" philosophy in programming, and I have a problem I thought might be solvable with logic programming. I mean this in a naive way, because I haven't ...
Bobby's user avatar
  • 41
2 votes
2 answers
356 views

I just read the primer for core.logic. It makes sense so far, but I'm not sure where to go to learn more. Let's say I wanted to write my own constraint, sort of like the membero shown in the primer. ...
Rob N's user avatar
  • 16.7k
1 vote
1 answer
125 views

I'm a beginner with logic programming. I'm trying to implement a sorting relation like this: (sorto [3 2 1][1 2 3]) -> #s I'am using clojure and core.logic: I don't understand why this can ...
szymanowski's user avatar
  • 1,379
1 vote
0 answers
92 views

I'm struggling with this simple relation, the results are incomplete, and I don't understand why. I'm beginning with core.logic I don't know if it is a bug or my bad understanding of it. (...
szymanowski's user avatar
  • 1,379
5 votes
2 answers
1k views

Does MiniKanren have the "not" operator? For example, how would one represent Prolog's a :- b, not(c) a is true if b is true and c is not (Prolog uses negation as failure, i.e. not(c) is considered ...
MWB's user avatar
  • 12.7k
3 votes
1 answer
275 views

I'm trying to solve the first puzzle in Smullyan's To Mock a Mockingbird using clojure.core.logic, not because it is particularly hard, but rather as an exercise. The puzzle states that there's a ...
Sebastian Oberhoff's user avatar
4 votes
1 answer
158 views

Say I want to get all combinations of bill/coins denominations that amount to a given value, given also a set of available denominations. So for instance, for (change 14 #{1 2 5 10}) I'd expect ( ...
alepeino's user avatar
  • 9,811
1 vote
0 answers
72 views

does anyone know how to quit / try the next condition in a conde, when a condition fails? As example: (run* q (conde [(conditionA) (conditionB) (conditionC)] [(conditionA) (conditionD) (...
GameYoker's user avatar
0 votes
1 answer
63 views

Just starting out with core.logic, version "0.8.11": (q/run* [q] (q/fresh [a] (q/membero a [2 3])) (q/membero q [1])) I don't understand the result: (1 1). My understanding is that I ...
nha's user avatar
  • 18.1k
1 vote
1 answer
433 views

According to wikipedia, prolog uses SLD Resolution. What are the principle algorithms driving the solving in core.logic?
matanox's user avatar
  • 13.9k
1 vote
1 answer
210 views

Is it possible to gainfully use core.logic from Java code? If so, would greatly appreciate a simple example. If not, could someone point to a pure-Java alternative?
Don's user avatar
  • 1,241
3 votes
1 answer
224 views

I'm curios if it is possible (and if so how should one implement) something like string-containso in core.logic. an example usage would be something like (db-rel person x) (def database (db ...
boogie666's user avatar
  • 650
0 votes
2 answers
229 views

I've been puzzled by a modelisation problem for some time and I have to confess I have no idea how I could "properly" solve it in core.logic. It is very easy to state: given a tree (acyclic ...
piotr-yuxuan's user avatar
4 votes
0 answers
57 views

I have hard time understanding the following behavior of the conjo goal in core.logic. First, everything seems fine. (l/run* [q] (l/conjo q 2 3 [1 2 3] )) => ([1]) The goal succeeds when q = [...
shaft's user avatar
  • 2,219
0 votes
1 answer
143 views

I'm trying to model an order relation between a finite set of tasks using core logic. This is what I have so far: (def tasks [:t0 :t1 :t2]) (defn tasko [x] (membero x tasks)) (db-rel before-...
Setzer22's user avatar
  • 1,699
1 vote
1 answer
158 views

Suppose we define a relation matches via the following table: |-----+-----+-----+-----+-----| | | *A* | *B* | *C* | *D* | |-----+-----+-----+-----+-----| | *A* | | X | X | | |-----+---...
George's user avatar
  • 7,357