Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Logic Programming
Search
Mario Alberto Chávez
October 14, 2014
Programming
0
83
Logic Programming
A quick exploration on Logic Programming... with Ruby and Ruby-Prolog
Mario Alberto Chávez
October 14, 2014
Tweet
Share
More Decks by Mario Alberto Chávez
See All by Mario Alberto Chávez
Ruby Internals V3
mario_chavez
0
45
Beyond the Rails Way
mario_chavez
1
67
Elm, una mejor manera de hacer frontend
mario_chavez
0
170
Rediscovering ActiveRecord
mario_chavez
2
300
Intro to Elixir
mario_chavez
0
120
From Ruby to Elixir: Developing Web Applications
mario_chavez
0
310
Pitch para Startups
mario_chavez
1
82
Understanding KPIs
mario_chavez
1
58
El nuevo comercio electrónico
mario_chavez
0
42
Other Decks in Programming
See All in Programming
元気予報
suu_mire0726
0
860
コーンフレークから始める モデリング会話入門
ogurotakayuki
0
280
スクラムチームと認知負荷 - ニフティのスクラムトーク Vol2. / NIFTY Tech Talk #18
niftycorp
PRO
1
120
今、知っておきたい! 生成AIエージェントの世界
elith
3
340
Java 22 Overview
kishida
1
170
puregoの活用例
aethiopicuschan
0
220
CA.swift19 恋するAIアプリ開発の裏側
oskmr
0
340
Elm Form Validation
bkuhlmann
0
500
GitHub Actionsで泣かないためにやっておきたい設定 / Recommended GHA settings to avoid crying
pinkumohikan
3
490
Ruby製社内ツールのGo移行
bgpat
2
330
スクラムガイドのスプリントレトロスペクティブを改めて読みかえしてみた / Re-reading the Sprint Retrospective Section in the Scrum Guide
mackey0225
3
330
Folding Cheat Sheet #2
philipschwarz
PRO
0
110
Featured
See All Featured
Visualization
eitanlees
135
14k
Fontdeck: Realign not Redesign
paulrobertlloyd
76
4.9k
4 Signs Your Business is Dying
shpigford
175
21k
Reflections from 52 weeks, 52 projects
jeffersonlam
344
19k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
29
6k
KATA
mclloyd
14
12k
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
How GitHub (no longer) Works
holman
304
140k
Bash Introduction
62gerente
604
210k
Large-scale JavaScript Application Architecture
addyosmani
503
110k
Building a Modern Day E-commerce SEO Strategy
aleyda
16
6.4k
Mobile First: as difficult as doing things right
swwweet
216
8.6k
Transcript
Logic Programming With Ruby Mario Chavez : @mario_chavez
We do love Ruby
Ruby has a story of borrowing features from other languages
Logic Programming with Prolog
Logic Programming • We do not express what a program
should do • We do express data and queries in a specific format
Main Blocks • Facts, assertions about our domain • Rules,
express inferences about our facts • Queries, questions to be answered
Ruby-Prolog https://github.com/preston/ruby-prolog
likes['wallace', 'cheese'].fact ! likes['grommit', 'cheese'].fact! likes['wendolene', 'sheep'].fact! friend[:X, :Y] <<=
[noteq[:X,:Y], likes[:X, :Z], likes[:Y, :Z]] query(friend['wallace', 'grommit']) rp = RubyProlog::Core.new! rp.instance_eval do! end
class Family < RubyProlog::Core! def initialize! super! facts! rules! end!
! def siblings(person)! query sibling[:X, person]! end! ! def parents(child)! query parent[:X, child]! end! ! def children(parent)! query parent[parent, :Y]! end! ! private! def facts! mother["Trude", "Sally"].fact! father["Tom", "Sally"].fact! father["Tom", "Erica"].fact! father["Mike", "Tom"].fact! end! ! def rules! sibling[:X,:Y] <<= [ parent[:Z,:X], parent[:Z,:Y], noteq[:X,:Y] ]! parent[:X,:Y] <<= father[:X,:Y]! parent[:X,:Y] <<= mother[:X,:Y]! end! end! ! s = Family.new! s.siblings 'Sally'!
Not as complete as Prolog But good enough to explore
a different way to solve problems
Be curious
Explore other languages
Gracias Mario Chavez : @mario_chavez