Fork me on GitHub
#clojure-italy
<
2017-08-17
>
reborg08:08:07

mmmh, qualche perplessita' sulla macro.. e' proprio necessaria?

reborg09:08:06

carino sto sprunge, prendo nota

richiardiandrea09:08:48

bello si, ma su Emacs si creano gist molto facilmente anche pure 😉

bronsa09:08:51

uso

(defun nopaste ()
  "Posts the current buffer or region to sprunge"
  (interactive)
  (let* ((start (if (use-region-p) (region-beginning) (point-min)))
         (end (if (use-region-p) (region-end) (point-max)))
         (content (buffer-substring-no-properties start end)))
    (async-start
     `(lambda ()
        ,(async-inject-variables "\\`content\\'")
        (let ((filename "/tmp/sprunge-post"))
          (with-temp-buffer
            (let ((coding-system-for-read 'utf-8)
                  (coding-system-for-write 'utf-8))
              (insert content)
              (write-file filename)))
          (substring (shell-command-to-string (concat "curl -s -F 'sprunge=<" filename "' ")) 0 -1)))

     (lambda (res)
       (kill-new res)
       (message res)))))

richiardiandrea09:08:20

bravo bello grazie 😄

kors09:08:45

Puoi anche eliminarla o eleggerla a funzione. Io sono arrivato alla conclusione che uso anche troppe poche macro 😄

reborg10:08:50

@kors comunque buon tentativo! Un'altra cosa che forse vale la pena: la funzione columns puo' andare, rimpiazzandola con (apply map vector game)

reborg10:08:47

Non che lo usi spesso... ma non avevo notato che (reduce + nil) chiama l'arity zero on +

bronsa10:08:55

user=> (reduce + nil)
0
user=> (reduce + nil [])
nil
user=> (reduce + [])
0
user=> (reduce + [1])
1

reborg11:08:35

e' un po' una palla, la arity-zero dev'essere li' perche' qualche clojure internals la richiede. Sbaglio?

reborg12:08:21

immagino reducers/transducers

reborg12:08:29

il commit e' li' dal 2012