Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

SICP, other texts

Name: Anonymous 2010-04-25 15:41

What's the big deal with SICP? Why does /prog/ recommend it for people learning programming? Is it because of the general outlook it gives you on programming (ex: programs aren't just instructions for a computer, but rather methodological paths to implement goals) and therefore gives a better understanding of how programming isn't a task but instead a definition that goes beyond computing? Is it because the language gives you insight into the fact that there are many different ways to get something done, unlike "modern" languages that simplify the API-calling-API-calling-API-calling-API system such that many programmers no longer have any idea of what they're actually doing?

Are there any other books or learning tools that /prog/ would recommend for functional (not functional vs imperative, but functional as in getting-things-done) learning?

Finally, what do the people of /prog/ do with their knowledge in programming with respect to computers and software? Hackers, task-men, etc.?

Name: Anonymous 2010-05-01 14:48

>>51
Like so?

module BBCode where

import Data.Char
import Data.List -- (intercalate)
import Control.Applicative

data BBCodeStyle = B | I | O | U | S | M | AA | Sup | Sub | Spoiler | Code
  deriving (Eq, Show)

data BBCodeText = Style [BBCodeStyle] BBCodeText | Text String
    | Sep BBCodeText [BBCodeText]
  deriving Show

render = putStrLn . go -- . optimize
  where go (Text s) = s
        go (Sep s bs) = go s `intercalate` map go bs
        go (Style ts bt) = makeTag ts $ go bt
        makeTag [] = id
        makeTag (x:xs) = surround (nameOf x) . makeTag xs
        nameOf = map toLower . show
        surround name text = concat ["[", name, "]", text, "[/", name, "]"]

-- This is useless right now but I want to use it to remove adjacent
-- closing/opening bbcode tags, which is the whole reason I did this all as
-- combinators instead of just passing strings around
optimize = go
  where go (Style [] t) = optimize t
        go (Sep (Text "") xs) = undefined -- let ys = groupBy sameStyle xs
        -- Breaks [sub][sub] etc. :(
        -- go (Style (x:xs@(y:ys)) t) | x == y = optimize (Style xs t)
        go anything = anything

sameStyle (Style (x:_) _) (Style (y:_) _) = x == y
sameStyle _ _ = False

buttsort fs = bbConcat . go (cycle fs)
  where go fs (' ':xs) = Text " " : go fs xs
        go (f:fs) (x:xs) = f [x] : go fs xs
        go _ [] = []

style xs = Style xs . Text
style1 = style . pure

[bbUnlines, bbUnwords, bbConcat] = map (Sep . Text) ["\n", " ", ""]

expert = style [B, I, O, U]
loveyourpost = bbUnwords $ zipWith style1 [B, I, O, U] $
  lines "I LOVE YOU!\nI LOVE YOUR POST!\nI READ IT FIVE TIMES!\nKEEP POSTING!"
fibsButtSort = buttsort [style1 U, style1 O]

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List