News for hackers. Stuff that matters.
Re:Lisp implementation in sed by rtpg on Saturday June 28, 2014 @03:38AM (#7957707)
this is more of a "symbols per line" argument rather than "symbols in the language" argument.

    grade = (student) ->
      if student.excellentWork
        "A+"
      else if student.okayStuff
        if student.triedHard then "B" else "B-"
      else
        "C"
(from coffescript examples)

Imagine how many more symbols that would have in any lisp dialect

Re:Lisp implementation in sed by lispm on Saturday June 28, 2014 @04:58AM (#7957796)

    (defun grade (student)
      (cond ((excellent-work student) :a+)
            ((okay-stuff     student) (if (tried-hard student) :b :b-))
            (t                        :c)))
Re:Lisp implementation in sed by illo on Saturday June 28, 2014 @05:33AM (#7957841)
Erlang, just for fun:

  grade(#student{work=Work, tried_hard=Tried}) -> grade1(Work, Tried).
  grade1(excellent_work, _) -> 'a+';
  grade1(okay_stuff, yes) -> b;
  grade1(okay_stuff, _) -> 'b-';
  grade1(_, _) -> c.
Edit: formatting.
Re:Lisp implementation in sed by JadeNB on Saturday June 28, 2014 @01:47PM (#7958776)
Or, if we're going to go with Prolog-inspired syntax, then why not Prolog?

    grade(Student, Grade) :-
        worked(Student, Work), work_grade(Work, Student, Grade).
    work_grade('Excellent', _, 'A+').
    work_grade('Okay', Student, 'B') :- tried_hard(Student).
    work_grade('Okay', _, 'B-').
    work_grade(_, _, 'C').
I'm a bit rusty, and I don't have a Prolog interpreter to hand to test, so I might have got some syntax wrong.
Re:Lisp implementation in sed by sfk on Saturday June 28, 2014 @10:02AM (#7958212)
I'm always amazed that I hardly ever program in Lisp and yet these short snippets are more readable than any other language.
Re:Lisp implementation in sed by dghf on Sunday June 29, 2014 @04:29AM (#7960694)
Yes, I've never understood why

    dostuff(x)
is considered so much more readable than

    (dostuff x)
Re:Lisp implementation in sed by bad_login on Saturday June 28, 2014 @05:25AM (#7957820)

   ;; comparing with racket:

   (define (grade student)
     (cond 
      [(excellent-work student) "A+"]
      [(and (okay-stuff student) (tried-hard student)) "B"]
      [(okay-stuff student) "B-"]
      [else "C"]))

   ;; Or

   (require racket/match)

   (define (grade student)
     (match (map (lambda (fn) (fn student)) 
                 '(excellent-work okay-stuff tried-hard))
       [(list #t _ _)  "A+"]
       [(list _ #t #t) "B"]
       [(list _ #t _)  "B-"]
       [else           "C"]))
Re:Lisp implementation in sed by dghf on Saturday June 28, 2014 @06:13AM (#7957899)
Clojure:

    (defn grade [student]
      (cond
        (excellent-work student)  "A+"
        (okay-stuff student)      (if (tried-hard student) "B" "B-")
        :else                     "C"))