2

I'm trying to do something very simple, write bytes to a file using the f library:

(require 'f)

And I create a list of bytes:

(setq random-data (loop for i from 0 to 40 collect (random 150)))

So far, so good. However, the unibyte-string function seemingly expects separate arguments so the following doesn't work:

(f-write-bytes (unibyte-string random-data) "file.dat")

This seems painfully easy but I can't get it working, is there a standard way of doing this?

Drew
  • 75,699
  • 9
  • 109
  • 225
Dave F
  • 553
  • 2
  • 13

1 Answers1

2

You need to apply the function to the list of arguments:

(f-write-bytes (apply 'unibyte-string random-data) "file.dat")

(apply '+ '(1 2 3)) is equivalent to (+ 1 2 3). See the section about calling functions in the elisp manual for more details.

dlukes
  • 241
  • 1
  • 5