Hacker Newsnew | past | comments | ask | show | jobs | submit | rol's commentslogin

If you have Quicklisp[1] installed you can install the "infix" package and get infix notation in Common Lisp[2]:

    $ sbcl
    This is SBCL 1.2.4.debian, an implementation of ANSI Common Lisp.
    More information about SBCL is available at <http://www.sbcl.org/>.
    
    > (ql:quickload 'infix)
    ; Loading package
    (INFIX)
    > #i(1 + 1)            ; addition
    
    2
    > #i(2^^128)           ; exponentiation
    
    340282366920938463463374607431768211456
    > (defun factorial (x)
         #i(if x == 0 then
              1
            else
              x * factorial(x-1)))       ; infix function call
    
    FACTORIAL
    > (factorial 5)
    
    120
    > #i(factorial(5) / factorial(6))
    
    1/6
    > '#i((a + b) * (c + d))      ; Put a ' before the #i() to see what code is generated
    
    (* (+ A B)
       (+ C D))
--

[1] - https://www.quicklisp.org/beta/ [2] - Don't know if there is a similar package for Scheme.


> Don't know if there is a similar package for Scheme.

I have to agree with others in the thread that infix in Lisp/Scheme is not the convention, and IMO an awkward fit. Don't recall encountering infix in any published/shared code I've seen, it may exist, but to learn Scheme becoming comfortable with s-expr notation is definitely necessary.

However, there is SRFI 105[0] which describes "curly infix expressions". It's implemented in Guile 2.x, possibly available in a few others but evidently not had a lot of uptake among Schemes.

[0] http://srfi.schemers.org/srfi-105/srfi-105.html

Edit: added URL


I wouldn't recommend using infix libraries if you really want to get into Common Lisp though. They're a bit of a crutch for people coming from other languages, but that's it.

Pretty much the whole language is based on Polish notation. The sooner you realise that + - * / are just function names like any other, the better you'll do.

For example:

  (+ 1 2 3)

  in plain symbols is just:

  (function parameter parameter parameter)
  
  But if I were to write my own addition function:

  (addition 1 2 3)

  it would also be:

  (function parameter parameter parameter)

  and so is:

  (http-request "http://www.google.com")

  (function parameter)
If you use infix notation, you're writing half your code in a competely different semantic to the other half. I can't imagine it helping people really get a proper grasp of how Common Lisp works.


Org mode[1] has some spreadsheet functionality which works fine as long as you don't use very large tables. Otherwise it gets a bit too slow.

You can also use those spreadsheets as input for pieces of code so you perform some analysis on their data.

--

[1] - http://orgmode.org/


> but still just 4 copies of any card

If you are playing Limited (i.e. Draft or Sealed decks) then you can have as many copies as you have in your card pool.

Although you may have some trouble finding 200 cards to use in a Limited event :)


glances is nice if you want to get an overview of your system resources:

https://github.com/nicolargo/glances

bmon and iftop can be used to see network usage:

https://github.com/tgraf/bmon/

http://www.ex-parrot.com/pdw/iftop/

Similar to iftop there is also iotop, but instead of showing network usage, it shows disk usage:

http://guichaz.free.fr/iotop/

Side note: There was a blog a couple years ago, which isn't being updated now, that would post reviews of CLI tools. Anyone that is interested in this topic should take a look at it:

https://kmandla.wordpress.com/software/

https://inconsolation.wordpress.com/ (new blog from the same person that did http://kmandla.wordpress.com)


In regards to Common Lisp, depending on which implementation you use you may get some sort of type checking at compile time.

For example, if you save the following code[1] into a file and try to load it into SBCL, it will give a compile time error:

    (ql:quickload 'defstar)
    
    (use-package 'defstar)
    
    (declaim (optimize (debug 3) (speed 0) (safety 3)))
    
    (defun* factorial ((x (integer 0 *))) ;; x is an integer from 0 up to +inf
      (if (zerop x)
          1
        (* x (factorial (1- x)))))
    
    (defun main ()
      (factorial "foo")  ;; Compile time error: "foo" conflicts with its assert type UNSIGNED-BTYE
      (factorial -1)     ;; Compile time error: -1 conflicts with its assert type UNSIGNED-BTYE
      (factorial 1.0)    ;; Compile time error: 1.0 conflicts with its assert type UNSIGNED-BTYE
      (factorial 0))     ;; Works

And when you load the file into SBCL you get the following error message (assuming you have Quicklisp installed):

    $ sbcl --load compile-time-safety.lisp 
    This is SBCL 1.2.7, an implementation of ANSI Common Lisp.
    More information about SBCL is available at <http://www.sbcl.org/>.
    
    SBCL is free software, provided as is, with absolutely no warranty.
    It is mostly in the public domain; some portions are provided under
    BSD-style licenses.  See the CREDITS and COPYING files in the
    distribution for more information.
    To load "defstar":
      Load 1 ASDF system:
        defstar
    ; Loading "defstar"
    
    
    ; file: /home/rol/src/lisp/compile-time-safety.lisp
    ; in: DEFUN MAIN
    ;     (FACTORIAL "foo")
    ; 
    ; caught WARNING:
    ;   Constant "foo" conflicts with its asserted type UNSIGNED-BYTE.
    ;   See also:
    ;     The SBCL Manual, Node "Handling of Types"
    ; 
    ; compilation unit finished
    ;   caught 1 WARNING condition

It's not as nice as Haskell's type system, but it's something :)

The main problem with this sort of compile-time checking is that it's implementation dependent, so some Common Lisp implementation may not provide it. You can configure the defstar library that I used on this code so that it automatically adds calls to "(check-type ...)". But then you are back at doing run-time checking of types.

--

[1] - The defstar library can be found on Quicklisp or here: https://bitbucket.org/eeeickythump/defstar/

It's pretty much just a nicer way to write all of the "(declaim ...)" and "(declare ...)" needed to provide the most information to the Common Lisp type system.


Just gonna hijack this thread to mention that if you use Gnus (the other Emacs mail client) to read your email you can use the variable "gnus-blocked-images" to block any images that match a URL.

Doing

    (setq gnus-blocked-images ".*")
will block all the images in the emails.

I tested it using "https://emailprivacytester.com" and the it picked up only the DNS prefetch link/anchor which I assume are due to my ISP and not Gnus.


Although having a central repository of code on the web is no longer unique to Perl, there is still some of CPAN's infrastructure that would be nice to have in other communities. For instance, cpantesters[1].

As far as I know, only the Lisp community has something similar to cpantesters in their cl-test-grid project.

On the other hand nowadays a language community could probably set up something similar to cpantesters using travis so hopefully we'll see more of those sort of systems in the future.

--

[1] - If you want to play buzzword bingo you can think about cpantesters as a distributed, fault-tolerant, self-organizing, volunteered run, cross-platform continuous integration platform that is free to end-users.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: