mdiep / logician Goto Github PK
View Code? Open in Web Editor NEWLogic programming in Swift
License: MIT License
Logic programming in Swift
License: MIT License
let x = Variable<Int>()
let goal: Goal = x != 5
Using Xcode 9, the compile failed with
Command failed due to signal: Segmentation fault: 11
It's good stuff and helps understand why I would want to use Logician.
As a way of adding constraints
// should find "mouse", "moose"
let fourLetterWords: AnyIterator<String> = solve { word in
return word.map { $0.length } == 5
&& any(
word == "dog",
word == "cat",
word == "mouse",
word == "moose",
)
}
Followup from #4.
map
lets you create a Property
, which acts as a unidirectional goal.
Bidirectional goals require mapping in both directions; hence bimap
.
For instance, integer multiplication would require division with no remainder. Given a * b == 12
where a
and b
are integers, b == 7
shouldn't unify.
let x: Variable<Int>
let goal: Goal = (5..<10).contains(x)
Using AnyIterator
has worked well so far, but it's started to feel a bit cumbersome. I think this will simplify the code.
You should be able to solve for something more than just a primitive type by solving based on its properties.
try
/catch
will work well in some places yet, but it'd be nice to have the types and it will enable some source improvements.
Should contain a code snippet, some links, and some examples uses.
How can I create a goal that depends on the value of two or more variables?
Given Variable<(A, B)>
, you should be able to get Variable<A>
and Variable<B>
.
Not sure what this should look like from an API standpoint. But the code to implement it already exists.
In order to optimize based on constraints, we need to be able to inspect constraints to some extent—instead of immediately evaluating them.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.