Uses a hash table to record previously seen lines. You can run this program in DrRacket, but it makes more sense from the command line.
To run the example, install Racket, start DrRacket, paste the example
program into the top area in DrRacket, and click the Run
button. Alternatively, save the program to a file and run racket
on
the file.
Form and function names in the code are hyperlinked to documentation, so click on them for more information.
#lang racket ; Simple web scraper (require net/url net/uri-codec) (define (let-me-google-that-for-you str) (let* ([g "http://www.google.com/search?q="] [u (string-append g (uri-encode str))] [rx #rx"(?<=<h3 class=\"r\">).*?(?=</h3>)"]) (regexp-match* rx (get-pure-port (string->url u)))))
Add a call to let-me-google-that-for-you
to get a list of search
results.
To run the example, install Racket, start DrRacket, paste the example
program into the top area in DrRacket, and click the Run
button. Alternatively, save the program to a file and run racket
on
the file.
Form and function names in the code are hyperlinked to documentation, so click on them for more information.
#lang racket ;; Report each unique line from stdin (let ([saw (make-hash)]) (for ([line (in-lines)]) (unless (hash-ref saw line #f) (displayln line)) (hash-set! saw line #t)))
#lang racket ; Simple web scraper (require net/url net/uri-codec) (define (let-me-google-that-for-you str) (let* ([g "http://www.google.com/search?q="] [u (string-append g (uri-encode str))] [rx #rx"(?<=<h3 class=\"r\">).*?(?=</h3>)"]) (regexp-match* rx (get-pure-port (string->url u)))))
Racket version 5.3.5 has been released.
Racket videos are now available.
RacketCon 2013 will be in September in Boston.
Draw more pictures or build a web server from scratch. Racket includes both batteries and a programming environment, so get started!
Racket's interactive mode encourages experimentation, and quick scripts easily compose into larger systems. Small scripts and large systems both benefit from native-code JIT compilation. When a system gets too big to keep in your head, you can add static types.
Extend Racket whenever you need to. Mold it to better suit your tasks without sacrificing interoperability with existing libraries and without having to modify the tool chain. When less is more, you can remove parts of a language or start over and build a new one.
Whether you're just starting out, want to know more about programming language applications or models, looking to expand your horizons, or ready to dive into research, Racket can help you become a better programmer and system builder.
Quick: An Introduction to Racket with Pictures gives you a taste of Racket.
More: Systems Programming with Racket dives much deeper and much faster, showing how to build a complete continuation-based web server.
Guide: Racket starts with a tutorial on Racket basics, and then it describes the rest of the Racket language.
Reference: Racket provides comprehensive coverage of all of Racket.
Continue: Web Applications in Racket describes how to use the Racket web server to build dynamic web applications.
Package Management explains how to install packages, and how to build and distribute your own.
RacketCon — the annual Racket meeting, coming up in September. Previously in 2012 and 2011.
Blog — announcements, helpful hints, and thoughtful rants.
Twitter — short bits of Racket news.
Mailing lists — discussion for using and developing Racket.
IRC — Chat in the #racket channel on freenode.net — an informal discussion channel for all things related to Racket. (Browse the logs.)
People — The people behind Racket.
Code — the Racket source code on GitHub.
Wiki — Useful pages include Intro Projects and Videos, including tutorials, interviews, and more.
Snapshot builds — The freshest versions of Racket.
Bug reports — File, query and maybe fix existing reports.