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
100
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
47
Beyond the Rails Way
mario_chavez
1
85
Elm, una mejor manera de hacer frontend
mario_chavez
0
210
Rediscovering ActiveRecord
mario_chavez
2
320
Intro to Elixir
mario_chavez
0
150
From Ruby to Elixir: Developing Web Applications
mario_chavez
0
400
Pitch para Startups
mario_chavez
1
120
Understanding KPIs
mario_chavez
1
82
El nuevo comercio electrónico
mario_chavez
0
63
Other Decks in Programming
See All in Programming
Haskell でアルゴリズムを抽象化する / 関数型言語で競技プログラミング
naoya
17
4.5k
人には人それぞれのサービス層がある
shimabox
3
670
レガシーシステムの機能調査・開発におけるAI利活用
takuya_ohtonari
0
600
AIエージェントによるテストフレームワーク Arbigent
takahirom
0
370
ktr0731/go-mcpでMCPサーバー作ってみた
takak2166
0
160
AIコーディング道場勉強会#2 君(エンジニア)たちはどう生きるか
misakiotb
1
180
UPDATEがシステムを複雑にする? イミュータブルデータモデルのすすめ
shimomura
1
540
Go Modules: From Basics to Beyond / Go Modulesの基本とその先へ
kuro_kurorrr
0
120
カクヨムAndroidアプリのリブート
numeroanddev
0
420
2度もゼロから書き直して、やっとブラウザでぬるぬる動くAIに辿り着いた話
tomoino
0
160
AWS CDKの推しポイント 〜CloudFormationと比較してみた〜
akihisaikeda
3
260
LINEヤフー データグループ紹介
lycorp_recruit_jp
0
480
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
650
Building an army of robots
kneath
306
45k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.8k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
Gamification - CAS2011
davidbonilla
81
5.3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
137
34k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
228
22k
Thoughts on Productivity
jonyablonski
69
4.7k
Speed Design
sergeychernyshev
31
990
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.5k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
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