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

Pages: 1-

Boku no Pico

Name: Anonymous 2011-05-27 15:06

Here is why Lisp unpopular...

http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(string_functions)

Ruby:         ["a", "b", "c"].join("-")
Perl:         join( '-', ('a', 'b', 'c'));
C#:           String.Join("-", {"a", "b", "c"})

Common Lisp:  (format nil "~{~a~^-~}" '("a" "b" "c"))

Name: Anonymous 2011-05-27 16:20

You find it hard to define a string-join function?

Name: Anonymous 2011-05-27 16:24

>>2
But I can take C# and have everything defined!

Name: Anonymous 2011-05-27 16:31

>>3
Not really true. I ended up learning Lisp just because C# didn't have nearly everything that I wanted.

Name: Anonymous 2011-05-27 16:44

>>1
No, the only reason why Lisp is unpopular are all the fucking parens. Practically anything else you don't like about it you can reimplement and/or tweak to your pleasure. Don't even dare mentioning Paredit.

[/thread]

Name: Anonymous 2011-05-27 16:45

>>4
If you want to do a simple database program, that works with string, then C# has everything, including MS SQL bindings.

Name: Anonymous 2011-05-27 16:46

>>5
Sorry, but "~{~a~^-~}" looks thousand times worse than parens.

Name: Anonymous 2011-05-27 16:52

>>7
I agree. So use string-join instead. Or write a printf clone. Just because someone found a fucktarded way of doing something doesn't mean the language is all bad.

Name: Anonymous 2011-05-27 16:55

>>6
Sure, it will have everything for popular ENTERPRISE work, but try venturing outside of that field and you'll find plenty of things it can't offer without major hacks, things which are just a few lines of code away in Lisp.

>>7
Nobody forces you to use format, there are alternatives to it and you're also free to manually work with strings if format isn't to your liking. Leaving that aside, the format string syntax isn't that hard to understand ~ is the escape character, so it could be looked at like: {a^-}. You don't see people complaining about % in C or {} in C#. Format strings tend to be the uglier part of a language.

Name: Anonymous 2011-05-27 17:37

>>9
You don't see people complaining about % in C or {} in C#.
Actually, I'm one of these people. "$a $b" is a way better than sprintf("%s %s", a, b) and you can easily embed your of formating functions "toHex($a) = $(toHex(a))"

Name: Anonymous 2011-05-27 17:38

>>10
you can easily embed your own formating
self fix

Name: Anonymous 2011-05-27 20:05

How about (append #'string [strings])?
No code tags for you.

Name: Anonymous 2011-05-27 20:19

>>12
No code tags for you.
AUTISTIC RAGEEEEEEEEEEE

Name: Anonymous 2011-05-27 20:28

>>1
The difference being, of course, that format is a general purpose string interpolation language, whereas join is just join.

Name: Anonymous 2011-05-27 21:20

>>12
append doesn't do what you think it does (it appends lists).

What you actually want is this:
(concatenate 'string string1 string2 ...)
But you would actually have to make that into an (apply #'concatenate 'string strings) where strings could be made by "zipping" (just a mapcar of the string sequence and a make-list of the delimiter) without the last element of the string and the delimiter.

This is how I personally implemented my string-join, it's some 4-5 lines of CL, however to tell you the truth, the format solution is better, and probably as fast if you use the formatter macro.
Here's a possible formatter expansion which implements string-join:

#'(LAMBDA
      (STREAM
       &OPTIONAL
       (#:FORMAT-ARG1064
        #:FORMAT-ARG1065
        (ERROR ...))
       &REST SB-FORMAT::ARGS)
    (DECLARE (IGNORABLE STREAM))
    (BLOCK NIL
      (LET* ((SB-FORMAT::ORIG-ARGS #:FORMAT-ARG1064)
             (SB-FORMAT::ARGS SB-FORMAT::ORIG-ARGS))
        (DECLARE (IGNORABLE SB-FORMAT::ORIG-ARGS SB-FORMAT::ARGS))
        (LOOP (WHEN (NULL SB-FORMAT::ARGS) (RETURN))
              (PRINC (IF SB-FORMAT::ARGS
                         (POP SB-FORMAT::ARGS)
                         (ERROR ...))
                     STREAM)
              (WHEN
                  (LET ((#:FVAR455 NIL) (#:FVAR456 NIL) (#:FVAR457 NIL))
                    (COND (#:FVAR457 (<= #:FVAR455 #:FVAR456 #:FVAR457))
                          (#:FVAR456 (EQL #:FVAR455 #:FVAR456))
                          (#:FVAR455 (EQL #:FVAR455 0))
                          (T (NULL SB-FORMAT::ARGS))))
                (RETURN))
              (WRITE-STRING #:FORMAT-ARG1065 STREAM))))
    SB-FORMAT::ARGS)


(This was edited in 2 places by hand because I somewhat hate format's language and can't remember how to properly back up an argument in a list, but I'm pretty sure a way exists, as long as you don't mind writing some linenoise)

Name: Anonymous 2011-05-27 21:50

>>14
format is a general purpose string interpolation language
And it's much harder than Lisp: try using format in macros.

Name: Anonymous 2011-05-28 3:30

lisp makes my code ugly, no matter what i do to it.

Name: Anonymous 2011-05-28 3:32

(join "a" "b" "c")

wow that was fuckin hard

Name: Anonymous 2011-05-28 6:10

>>15
Oh right, I meant concatenate .
Silly mistake.

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