Planet Scheme

May 21, 2013

Ben Simon

Forth in Racket, Mind-bending and Beautiful

Jay McCarthy's efficient implementation of Forth in 85 lines of Racket is beautiful. It demonstrates how you can integrate two different programming paradigms in one environment, and it does so with some impressive macro-fu. Consider his goals:

  1. We must be able to define functions in Forth that are callable from Forth, always.
  2. We must be able to give functions stack effect annotations to enable them to be called from Racket.
  3. We must be able to lift Racket functions to Forth so they are oblivious to the stack, like turning + into :+.
  4. We must be able to lower Racket functions to Forth so they can directly affect the stack, like writing :over.
  5. We must be able to enter Forth from Racket arbitrarily, such as to write testing forms like check-forth.

Meeting all those goals is an impressive feat.

As a functional tool, I'm not sure I see much of a use for it (yet). As a novel case study and series of examples, it's fantastic.

by Ben Simon (noreply@blogger.com) at May 21, 2013 12:03 PM

Programming Praxis

Coin Change, Part 2

In the previous exercise we studied the classic coin change problem to find all the ways to make a given amount of change using a given set of coins. Sometimes the problem in a different way: find the minimum set of coins needed to make a given amount of change. As with the prior exercise, sometimes the task is to find just the count and sometimes the task is to find the actual set of coins.

Your task is to write the two programs described above. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.


by programmingpraxis at May 21, 2013 09:00 AM

May 20, 2013

Grant Rettke

Husk: An R5RS-compatible Scheme written in Haskell

Husk is a dialect of Scheme written in Haskell that adheres to the R5RS standard. Advanced R5RS features are provided including continuations, hygienic macros, and a full numeric tower.

(via husk-scheme)

by Grant at May 20, 2013 08:18 PM

Jay McCarthy

May 17, 2013

Programming Praxis

Coin Change, Part 1

It is a classic problem from computer science to determine the number of ways in which coins can be combined to form a particular target; as an example, there are 31 ways to form 40 cents from an unlimited supply of pennies (1 cent), nickels (5 cents), dimes (10 cents) and quarters (25 cents), ranging from the 3-coin set (5 10 25) to the 40-coin set consisting only of pennies.

The solution is usually stated in recursive form: if c is the first coin in the set of coins cs and n is the target, the solution is the number of ways to reach the target after removing c from cs plus the number of ways to reach nc using all the coins in cs. The algorithm to make a list of the coins, instead of the count, is the same, but keeping track of the list of coins instead of the count.

Your task is to write two functions, one to determine the count and one to determine the list of coins. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.


by programmingpraxis at May 17, 2013 09:00 AM

May 15, 2013

Jeremy Kun

Properties of Morphisms

This post is mainly mathematical. We left it out of our introduction to categories for brevity, but we should lay these definitions down and some examples before continuing on to universal properties and doing more computation. The reader should feel … Continue reading

by j2kun at May 15, 2013 05:43 PM

Grant Rettke

ISLISP

The ISLISP programming language is a member of the Lisp family of programming languages. It attempts to bridge the gap between the various incompatible members of the Lisp family of languages (most notably Common Lisp, Eulisp, LeLisp, and Scheme) by focusing on standardizing those areas of widespread agreement. It is a small language, closer to the size of Scheme than to Common Lisp, for example.

The most recent change to the specification occurred in 2007.

The design of ISLISP had these design goals:

  • Compatible with existing Lisp dialects where feasible.
  • Provide basic functionality.
  • Object-oriented.
  • Designed with extensibility in mind.
  • Gives priority to industrial needs over academic needs.
  • Promotes efficient implementations and applications.

(via islisp.info)

John Cowan mentioned it on scheme-reports, so I was curious.

by Grant at May 15, 2013 04:39 PM

May 14, 2013

Programming Praxis

Optimal Alphabetical Order

Today’s exercise comes from the book Making the Alphabet Dance: Recreational Wordplay by Ross Eckler, but I found it at http://www.math.cmu.edu/~bkell/alpha-order/:

Assume we have a list of all the words in the English language. Under the normal ordering of the alphabet in English (A, B, C, …, Z), some number of these words have all their letters in alphabetical order (for example, DEEP, FLUX, and CHIMPS). However, if we change the ordering of the alphabet, we will change the number of words having their letters in “alphabetical” order. What arrangement of the letters of the alphabet maximizes this number?

Your task is to write a program to find such an arrangement. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.


by programmingpraxis at May 14, 2013 09:00 AM

May 13, 2013

Jeremy Kun

“Dog” Print Available for Sale

My girlfriend and I decided we want a print of my recent artistic creation from the post Bezier Curves and Picasso. I set up an account at Society6, which does professional art printing (framed or unframed).  I can’t imagine anyone … Continue reading

by j2kun at May 13, 2013 05:58 PM

Grant Rettke

mickey-scheme

Mickey Scheme is an interpreter for R7RS Scheme written in C++

by Grant at May 13, 2013 12:59 PM

Jay McCarthy

May 11, 2013

Jeremy Kun

Bezier Curves and Picasso

Simplicity and the Artist Some of my favorite of Pablo Picasso’s works are his line drawings. He did a number of them about animals: an owl, a camel, a butterfly, etc. This piece called “Dog” is on my wall: These … Continue reading

by j2kun at May 11, 2013 05:32 AM

May 10, 2013

Programming Praxis

MindCipher

According to their masthead, the MindCipher website is “a social repository of the world’s greatest brain teasers, logic puzzles and mental challenges.” Some of the problems lend themselves to brute force computation, others are better solved with pencil-and-paper or solely with mental effort. We look at three MindCipher exercises today.

1: Coin Flip: On Monday, you flip a coin all day. You start flipping it until you see the pattern Head, Tail, Head. You record the number of flips required to reach this pattern, and start flipping again (and counting up from 1 again) until you see that pattern again, you record the second number, and start again. At the end of the day you average all of the numbers you’ve recorded. On Tuesday you do the EXACT same thing except you flip until you see the pattern Head, Tail, Tail.

Will Monday’s number be higher than Tuesday’s, equal to Tuesday’s, or lower than Tuesday’s?

2: 1978: The year 1978 is such that the sum of the first two digits and the latter two digits is equal to the middle two digits, i.e. 19 + 78 = 97. What is the next year (after 1978) for which this is true?

3: Sum of Two Prime Numbers: If p, q > 2 are consecutive in set of primes. Since p,q can only be odd number, (p+q) is an even number.

Can (p+q)/2 be prime?

Your task is to solve the three problems given above; write a computer program to help you if you wish. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.


by programmingpraxis at May 10, 2013 09:00 AM

May 08, 2013

PLT Scheme

Racket v5.3.4

Racket version 5.3.4 is now available from
http://racket-lang.org/
  • Extflonums (80-bit floating-point numbers) are supported on some x86/x86_64 platforms — including Windows, and including platforms where Racket is compiled to use SSE instructions for flonum arithmetic. Thanks to Michael Filonenko.
  • OS X: DrRacket and all of the other apps are now signed with an official key.
  • Tally Maze: a new game based an enumeration of 2d mazes.
  • The Optimization Coach, a DrRacket plugin, has been moved from the Racket distribution to the Racket package repository. Install it with: raco pkg install optimization-coach.
  • Redex: define-union-language now merges productions when languages define the same nonterminals. Thanks to William Bowman.
  • The srfi/19 library is now compatible with the date structure type exported by racket/base.

by Eli Barzilay (noreply@blogger.com) at May 08, 2013 04:44 PM

RacketCon 2013

We are pleased to announce that (third RacketCon) will take place on September 29, 2013 at Northeastern University in Boston.  This year, we plan to bring in several speakers from industry, as well as host talks from Racket developers and users.

Lunch will be provided.

On the Saturday (28th) before RacketCon, we plan to hold a hackathon to work on various Racket projects.

Registration will open during the summer, and we will post a detailed schedule of events around the same time. The conference website is at

http://con.racket-lang.org/

by Asumu Takikawa (noreply@blogger.com) at May 08, 2013 03:53 PM