Skip to content

Instantly share code, notes, and snippets.

@ncollins
ncollins / proplogic.ml
Last active March 15, 2016 13:59 — forked from raoprasadv/proplogic.ml
Rewrite based resolution for computing well-founded semantics of a propositional logic program.
(** proplog.ml:
* Author: Prasad Rao
* Email: raoprasadv AT gmail DOT com
* use propositional logic to show principles of
* prolog resolution
* using SLG (http://link.springer.com/chapter/10.1007/3-540-63255-7_33#page-1)
* for computing Well-founded semantics of a propositional logic program
*
* Intended for use as a teaching tool.
*)
import Keyboard
moveElement leftBorder rightBorder deltaX oldX =
max leftBorder (min rightBorder (oldX + deltaX))
move : Int -> Int -> Int
move = moveElement 0 100
input : Signal Int
input = let deltaX = lift (\a -> a.x) Keyboard.arrows
# find the sum of all numbers, less than one million,
# which are palindromic in both base2 and base10
class Integer
def palindrome?
self.to_s.reverse == self.to_s
end
# checks to see if an integer is
# palindromic in both bases.
def ppp?
=begin
First 10 pentagonal numbers:
[1, 5, 12, 22, 35, 51, 70, 92, 117, 145]
their differences:
[4, 7, 10, 13, 16, 19, 22, 25...]
their sums:
[6,17,34,57,86,]
It can be seen that P^4 + P^7 = 22 + 70 = 92 = P^8.

Keybase proof

I hereby claim:

  • I am ncollins on github.
  • I am ncollins (https://keybase.io/ncollins) on keybase.
  • I have a public key whose fingerprint is DB3A DBE1 14A0 5D93 AD5F 2EB9 FAB4 E15A 8801 E754

To claim this, I am signing this object:

@ncollins
ncollins / tictactoe.rb
Last active December 26, 2015 17:18
initial work for Tic-Tac-Toe in Ruby with @syntacticsugar
# 1. a model class that handle the game logic
# 2. a view class that handles the console output (display)
# 3. a controler class that handles user input
class TicTacToe
def initialize
@board=[[0,0,0],[0,0,0],[0,0,0]]
end
def take_turn(player,row,column)
class Celery
def initialize(grid)
@grid = grid
@height = grid.length
@width = grid[0].length
end
def self.mini
[[ 0, 1, 2, 3, 4],
[10,11,12,13,14],
[20,21,22,23,24],