Drakevr's Corner

Me in Hashtags: #sysadmin, #programming, #networking, #student, #Linux

Scheme? Functional Programming? Why?

Apr 25, 2013 - 3 minute read - Comments - chickenvimscm

Studying functional programming is an opportunity to greatly broaden your horizons, discover a whole new way to represent programs, to approach problems and reach solutions while thinking about languages. Programming in a functional language is pretty much fundamentally similar to programming in any other type of language (like logic programming), it represents programs and algorithms through distinct forms of abstraction and gives you a new toolset with which to solve programming problems. many of the techniques of functional programming are beginning to be included in new mainstream languages, so taking the time now to immerse yourself in them will leave you with a headstart and a thorough understanding of those techniques.

In that regard i started learning Scheme and reading/solving the exercises in the book “Structure and Interpretation of Computer Programs. Scheme is a very small language which is one of the two major lisp dialects (the other being Common Lisp), one of the oldest functional programming languages. Scheme is small and elegant (the entire language can be built on top of a handful of primitive list manipulating operations), there is also a multitude of sources and educational material to choose from (should you decide to study it too). As such, Scheme is the perfect place to dive into the techniques of functional abstraction. In your new venture make sure to have a look and get accustomed with techniques like:

  • recursion
  • macros
  • closures
  • first class functions
  • lamda expressions

Vim ? with a Lisp Variant?

Yes, i love vim and in no way am i changing editor just to write in a new language so no Emacs is not an option.

Movement

" A few lisp specific settings
 set lisp               " enable vim's lisp mode
 set autoindent         " new lines copy previous indent 
 set showmatch          " shows matching paren/brace/bracket
 set cpoptions=-m       " when included a showmatch will always wait half a second,
                        " when not it will either wait half a second or until you type a char.
 set foldmethod=indent  " fold indented text

 %     " find the matching paren/brace/bracket
 [(    " go to previous unmatched "("
 [)    " go to previous unmatched ")"

 " this saved me a few keystrokes
 :map [9 [(
 :map [0 [)

 " these can help for searching "(" or ")"
 :map <C-F9> /(<cr>
 :map <C-F10> /)<cr>

 " selecting stuff
 ib   " inner block selection
 ab   " outer block selection

 " like C you can indent and reindent stuff with "=" and "=="

TSlime.vim

TSlime is a simple vim script to send portion of text from your vim buffer to a running interpreter session. You only need to be running vim inside a tmux session and provide the session name,window,pane number to tslime so that it knows where to send subsequent commands.

Then you just select your desired block of text and send it over with

Tags:

Single file VCS Fosscomm 2013 at Athens

comments powered by Disqus