News for hackers. Stuff that matters.
Re:April, an APL Compiler for Common Lisp [video] by phantomics on Friday September 11, 2020 @01:49PM (#24445350)
April is usable within Common Lisp. When writing a CL program, you can invoke APL code on arrays. For example:

(april-c "{⍴∪,(3⍴2*8)⊥3 1 2⍉⍵}" (opticl:read-png-file "/path/to/image.png"))

This snippet uses the opticl library to load a PNG file, and then uses April to count the number of unique colors in the image. Consider the amount of code this would take in CL.

Re:April, an APL Compiler for Common Lisp [video] by smabie on Friday September 11, 2020 @03:20PM (#24446363)
It would be cool if it was implemented as a reader macro instead of just passing a string to a function.
Re:April, an APL Compiler for Common Lisp [video] by phoe-krk on Friday September 11, 2020 @04:23PM (#24446957)
Do it yourself! (Implementation loosely based on phantomics' comment below.)

    (defun april-reader (stream char)
      (declare (ignore char))
      `(april ,(read stream t nil t)))
    
    (set-macro-character #\⎕ #'april-reader)
Re:April, an APL Compiler for Common Lisp [video] by Avshalom on Friday September 11, 2020 @04:43PM (#24447144)
You're probably gonna want something more complicated than that. Glancing at the github page it looks like at least the following need to be dealt with:

  (april "apl code") ; and april-f
  (april (with (stuff)) "apl code") ; and april-f
  (april-c "apl code" (input))
  (april-c (with (stuff)) "apl code" (input))
Re:April, an APL Compiler for Common Lisp [video] by phoe-krk on Friday September 11, 2020 @04:49PM (#24447198)
Yes, the above is a trivial implementation; handling multi-form input would need to be much more complex. Thankfully, for simple one-liners, you'll likely want either April literals (implemented above) or April anonymous functions, both of which won't take additional arguments; you should be able to implement both as simple reader macros.
Re:April, an APL Compiler for Common Lisp [video] by phantomics on Friday September 11, 2020 @03:30PM (#24446448)
Wouldn't be too hard to do, someone in the video suggested a #⎕ reader macro followed by APL. Like take '#⎕string' then expand that to '(april "string")'.

But April has many ways of passing options and external data for the compiled code to operate upon, and implementing a reader macro system that would support all those parameters would be complicated and require developers to learn a bunch of new syntax in order to use April with reader macros.

Re:April, an APL Compiler for Common Lisp [video] by phantomics on Friday September 11, 2020 @07:12PM (#24448303)
Another option is to load APL source from a file.

(april-load #P"/path/to/code.apl")

Then you can have files of pure APL code with no Lisp hanging around.

Re:April, an APL Compiler for Common Lisp [video] by e12e on Friday September 11, 2020 @07:53PM (#24448582)
> Consider the amount of code this would take in CL.

I don't really read APL - but isn't this just a map/reduce over the pixels? - maybe (length (remove-duplicates 'pixel-data)) or some such?

Re:April, an APL Compiler for Common Lisp [video] by phantomics on Friday September 11, 2020 @08:26PM (#24448758)
The pixels aren't singular values, the image is a height×width×3 array of 8-bit integers. The third dimension is the three RGB values for each pixel. The bulk of the string, the "(3⍴2*8)⊥3 1 2⍉⍵" part, converts the array into a height×width matrix of 24-bit integers representing the colors. Once you have a matrix M, "⍴∪,M" is all the code needed to count the unique values.