Skip to content

jiaaro/pfactory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

pfactory 0.1.1

A crappy, incomplete implementation of Factor as a Python DSL

This was inspired by Jon Purdy's, “Why Concatenative Programming Matters

Example code:

    assert parse("3 2 -")() == 1
    assert parse("2 -")(3) == 1
    assert parse("3 2 *")() == 6
    assert parse("2 3 * 4 5 * +")() == 26
    
    countWhere = parse("filter len")
    assert countWhere(lambda x: x < 3, range(5)) == 3
    
    # python's filter kind of sucks for use in factor because 
    # the data is not the first argument
    fltr = lambda data, fn: filter(fn, data)
    countWhere = parse("fltr len")
    assert parse("[2 >] countWhere")([1,2,3,4,5,]) == 3

Additional Notes

This is a learning exercise, not a library intended for actual use.

If someone likes this and wants to work on it - cool! - but just know, you're probably better off just using the real Factor Compiler and calling it as a subprocess :)

About

A Crappy implementation of factor (http://factorcode.org) as a python DSL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages