Lisp

53 readers
3 users here now

founded 1 year ago
MODERATORS
101
 
 

I want to call the square root of 9 from Math:

I tried the following, but it does not work:


(defun main
    (format t "~a~%"
        (JAVA:JCALL (JAVA:JMETHOD "java.lang.Math" "sqrt" 9.0))))
(main)


Can someone provide a working ".lisp" file which calls the java sqrt function from 9 and prints the result 3 for the abcl implementation ?

102
 
 

No commits on GitHub since 2022, the slack channel is dead silent, and it seems everyone here recommends deps.edn. Is Leiningen worth using in 2023 or should I jump ship?

103
104
105
 
 

For example, I've seen someone defining a package like so:

(defpackage :foobar
  (:use :cl))

instead of:

(defpackage foobar
  (:use cl))

Is there any actual difference? Or it's just a personal preference, and has no effect on the program at all?

106
107
108
109
110
 
 

I'm about to start a personal project and I'd love to use XTDB, but I'm not quite sure I should use it instead of a SQL db like eg. Postgres. The reason why I'm not sure is that I don't know if I'll be able to write complex queries in Datalog that I'd otherwise with SQL. I know this is kind of an open-ended question, but is it possible to write complex queries with joins and aggregations in Datalog? Or perhaps a better question is, what are the things that Datalog cannot do that SQL can?

111
 
 

Seems as if one wants to learn lisp, one has to learn emacs first. That said, I am looking for resources for the absolute beginner to learn emacs, looking for something along the lines of Common lisp A gentle introduction to symbolic computation., but for emacs. Something that assumes you know nothing, starts at the absolute beginningwith lots of exercise and answer to those exercise.
Any help will be appreciated. Thanks

112
 
 

Seems as if one wants to learn lisp, one has to learn emacs first. That said, I am looking for resources for the absolute beginner to learn emacs, looking for something along the lines of Common lisp A gentle introduction to symbolic computation., but for emacs. Something that assumes you know nothing, starts at the absolute beginningwith lots of exercise and answer to those exercise. Any help will be appreciated. Thanks

113
 
 
  1. A program, written in CL, is a huge mutable state. It seems that one can redefine nearly every symbol and there is no immutable data structures. But, as far as I understand, one can modify the language by using macros. So, is it possible to create a macro, which protects data structures from mutation or forbids the usage of mutable operators. For example:
(defmacro with-immutable-scope (&body body)
  ...)
(with-immutable-scope
  (let ((q (list 1)))
    (setf q 1))) => compilation error
  1. A public interface of a CL package consists of symbols. How can I specify and find out, what a symbol from a different package refers to? Should I do the following:

To specify what I export:

(defpackage :foo
  (:use :cl)
  (:export
   ;; macros
   :with-immutable-scope
   ;; functions
   :fetch-data
   ...

To find out what I import:

(describe fetch-data)
  1. When I create a variable binding with `let` and then modify the variable, this modification doesn't propagate through the binding. Example:
(defstruct point x)
 (let* ((point-obj (make-point :x 1))                                                      
        (x-ref (point-x point-obj)))                                                       
  (setf x-ref 2)                                                                          
  (point-x point-obj)) ;; => returns 1 because setf changed the reference to point-x but not the point-x itself

Does it mean that the let-bindings are effectively read-only pointers?

  1. How can I remove a method, which was previously associated with a generic function? For example:
(defgeneric foo (x))
(defmethod foo ((x list))
	   "list")
(defmethod foo ((x integer))
	   "integer")
(fmakeunbound-for-clos-methods '(foo (x integer))) ;; <- need help here
(foo '()) ;; => "list"
(foo 1)   ;; => NO-APPLICABLE-METHOD-ERROR

Does `fmakeunbound-for-clos-methods` exist ?

114
115
 
 

Hi guys, I was wondering if there were some concepts in category theory that'd be practical/pragmatic to be used in Clojure. Ik that category theory can sometimes get too abstract such that it will be confusing or straight up not optimal in Clojure. But still i thought there might be some concepts that were practical and might fit well into Clojure. So if anyone here have good experience with category theory or ml have you discovered some design patterns/concepts that are a good fit for Clojure

116
 
 

Please see readme-sailfish.

This uses the Qt5.15 meta packages, and needs an app called qt-runner for launching the apps in a separate wayland client, providing also the SailfishOS keyboard.

So, it's not 'native' in the look & feel sense (no Sailfish specific QML items available), but allows basically any Qt5.15 compiled app to run on SailfishOS, which is great news!

Obligatory screenshot: cl-repl-sailfish

117
 
 

We've just released a first-class Clojure API for Rama. Rama is a new programming platform we released in August that enables end-to-end scalable backends to be built in their entirety in 100x less code than otherwise. It's a "programmable datastore on steroids" where you mold your datastore to fit your application rather than the other way around. The introductory blog post to the Clojure API culminates in building a highly scalable auction application with timed listings, bids, and notifications in only 100 LOC.

118
 
 

A counter in racket-scheme:

#lang typed/racket

(define my-counter!
    (let ([t 0])
        (lambda ()
	        (set! t (+ 1 t))
	    t);lambda
	);let
);define 
(print (my-counter!))
(print (my-counter!))

A counter in sbcl-lisp:

load "~/quicklisp/setup.lisp")

(declaim (optimize (speed 3) (safety 3)))

(let ((c 0))
    (defun my-counter! ()
        (lambda ()
            (setf c (+ 1 c))
	    c); lambda
	 ) ;defun
) ;let

(defun main ()
(print (funcall (my-counter!)))
(print (funcall (my-counter!)))
)

(sb-ext:save-lisp-and-die "test.exe" :toplevel #'main :executable t)

Could someone elaborate why i need "funcall" in lisp and not in scheme ? And why the different placing of let ?

119
 
 

I had the honor and the pleasure to demo an AI-augmented user interface during a recent meetup. Since the demo is online and publicly available, I am inviting anyone who might be interested to try it out. The audience for this demo is, I'd venture to say, front-end developers, designers, and photographers.

As an amateur photographer myself, I frequently post photos on social media. There are lots of forums out there, and it becomes quickly apparent that different communities have different rules as to how a post should look like. For example, subreddits often require that the type of lens be mentioned in the title. Posts need to be tagged differently if the image is straight from camera (SOOC) or post-processed. Crafting a post isn't terribly difficult, but some details can be gleaned from the embedded EXIF data in a more reliable way than from the shooter's memory. Also, I wanted to see how helpful image recognition could prove in this context.

So I set out to build a user interface that only requires one action from the user: uploading a photo. All the rest is done via asynchronous requests that integrate with the UI. EXIF data is extracted on the server, AI-generated tags come from a third-party image recognition service. The challenge is to display the information seamlessly, as it comes in from the various sources, without startling the user.

Here is the demo. Special thanks to Scicloj for hosting me with grace and kindness. If you're not familiar with that organization yet, check it out.

Have you tried uploading a photo from your own devices/cameras? What are your thoughts? Is there something you would have done/seen differently? Please let me know.

120
121
122
123
 
 

Hello everyone!

I apologize for the consecutive posts and any disturbance caused. I've written an article about why I'm passionate about Lisp development. If you're interested, please take a look. Thank you Rediscovering the Joy of Math: A Journey with Lisp | by Kenichi Sasagawa | Oct, 2023 | Medium

124
 
 

Hello everyone.

I wrote an article reminiscing about my childhood when I used to build radios and amplifiers. Please take a look if you're interested. Rediscovering the Joy of Hardware Hacking with Raspberry Pi and Lisp | by Kenichi Sasagawa | Oct, 2023 | Medium

125
 
 

I just added a short chapter on using the Anthropic completion API to my Common Lisp book. Here is a link to the start of the new material https://leanpub.com/lovinglisp/read#leanpub-auto-using-the-anthropic-claude-llm-completion-api

If you have been using OpenAI’s APIs from Common Lisp and want to try using Anthropic, this new material should save you a few minutes work getting setup.

view more: ‹ prev next ›