RSS

Category Archives: Lisp

Lisp, Common Lisp, Scheme ve Lisp ile bağlantılı her şey…

How to edit remote files within Emacs when a program automatically runs after you SSH


If you are used to TRAMP functionality of Emacs to edit remote files without leaving the comfort of your beloved editor on your host machine, you do your best to keep it working even when different conditions arise. In my case, I’ve been recently working with virtual machines at work and the product that I’m working on is configured to run some program automatically right after I log into the machine via SSH. This prevents TRAMP functioning correctly with its default settings, because instead of receiving the shell prompt immediately, it receives from the machine the final line of the program that automatically runs and expects the user enter some response:

    ... some text menu options ...
    ...
    Please make a selection >>

Above that line, the text menu says that the user should enter 0 to exit the program or some other menu option to continue. Therefore, I had to find a way to tell Emacs that it had to send a 0 after it connects to the machine. The high-quality TRAMP manual was immediately helpful by providing a relevant example and I came up with the following: Read the rest of this entry »

Advertisements
 
2 Comments

Posted by on November 30, 2015 in Emacs, Lisp, Programlama

 

Tags: , , ,

How to detect Friday the 13th with full moon using Emacs


nrAlmost 21 years ago, in 1994, I bought the brand new edition of Numerical Recipes in C: The Art of Scientific Computing. As an engineering and mathematics student who was much into programming, I still remember my excitement then, as well as the bright red hard-cover.

The first algorithm presented in the book (and its implementation in C programming language) was about calculating the dates that were Friday the 13th and had full moon. Now that I’m approaching the 21st anniversary of that day, I wanted to share a similar program to detect if the current date is Friday the 13th with full moon. This time, my preference is for Emacs Lisp, and instead of re-implementing the same algorithm, I simply use the calculations already provided by Emacs. In other words, I rely on the lunar-phase-list function that returns the lunar phases of the upcoming dates given a month and a year.

It’s been ages since I’ve done Common Lisp programming and many years since I’ve practiced Emacs Lisp, so the code below is probably not optimal and idiomatic, but nevertheless it follows:

You can used the function defined above to see whether it is your “unlucky” day:

This will return “Good luck!” most of the time, luckily! 🙂

Can you come up with other ways of detecting Friday the 13th with full moon using existing utilities, such as GNU calendar program? Or, how would you calculate the next 10 Friday the 13ths that had full moon, using Emacs Lisp or some existing utility?

 

 
Leave a comment

Posted by on November 12, 2015 in Emacs, Lisp, Programlama

 

Tags: , ,

What happens when you try 1 / 3 in different SPARQL processors? Meet the semantics of mathematics of the Semantic Web


Recently, Dr. Frithjof Dau from SAP Research has posed an interesting SPARQL question in the context of the CUBIST project that led to more questions and interesting discoveries as well as mathematical annoyances. For all those semantic web enthusiasts and SPARQL nerds out there, can you guess the results of the following SPARQL query, along with the associated types, but of course without actually running the query using a SPARQL engine?

Read the rest of this entry »

 
Leave a comment

Posted by on July 20, 2012 in Lisp, Math, Programlama

 

Tags: , , , , ,

How to subtract a number from the current word and replace the result (in Emacs Lisp)


I needed to do some Emacs Lisp hacking for a little project (there are more conventional methods but they don’t have the sheer pleasure of hacking Lisp ;-)). Basically I wanted to come up with a function that takes the current word, converts it into an integer, subtracts some number from it, converts the resulting number into a string again and then replaces the original “word” with the new value:

 
Leave a comment

Posted by on December 20, 2011 in Emacs, Lisp, Programlama

 

Tags: , ,

The Use of Applied Mathematics in Music to Produce Spontaneous Change


It is great to hear that Aykut Çağlayan completed his Ph.D. thesis on algorithmic music composition:

In the course of western classical music, algorithmic procedures have been integral to composition techniques . After the computer revolution, those procedures became prevalent and deepened among composers. Accordingly, the use of computer and its fast computational power opened new dimensions in the research of dynamical systems and modelling self-organisation in the nature. The reason for mentioning artistic and scientific methods side by side is that i think that there is a direct relationship between aesthetical and epistemological fields and the mimetic attribute of art came to prominence in this dissertation. In that sense, the mathematical models of the natural self-organisation; Cellular Automata and random Boolean networks and Markov chains are surveyed in this dissertation. And new techniques by using those systems to produce music and sound have been developed. Cellular Automata and random Boolean networks depends on the interactions of cells, which constitutes the system and are capable of emergent behaviour. Even these systems are deterministic, they are not predictable. The micro interactions produce complex structures in the macro level. The coherent and synchronous evolution of plural constituents are very fruitful in algorithmic composition. Yet, the basic two concepts regarding musical aesthetics are intrinsic to that systems: coherence and variation/evolution. Nevertheless, the mentioned systems are presented in limited time/space dimensions. Henceforth the problem of this dissertation is, transposing the mathematical idealizations into musical time in a natural way rather than mechanical time steps. The last parts of chapters (2nd, 3th and 4th) include my original approach to this problem. My approaches are flexible interpretations of Cellular Automata generations, the interpolation between two Markov tables (melodic morphing), assigning each cells to a function, which has a memory and recursive. The use of random Boolean networks in algorithmic composition literatur have not been available until this dissertation. Non-local interactions between the elements of RBN is very inspiring for algorithmic composition. The prominent quality in my approach is assigning each cell to a function. The codes and the resulting scores are given within the text and the sound examples are attached to text within a CD.

You can read his thesis at http://www.fileden.com/files/2009/12/26/2703030//Caglayan_DoktoraTezi.pdf, download his CD from http://www.fileden.com/files/2009/12/26/2703030/DoktoraTezi-Ek_CD.zip, and leave your comments at his blog: http://aykut-caglayan.blogspot.com/2010/09/doktora-tezim-my-dissertation.html.

Read the rest of this entry »

 
Leave a comment

Posted by on December 9, 2010 in Lisp, Math, Music, Programlama, Science

 

Educational Functional Pearl: "Little language" project modules


I’ve recently read the article titled “Little language project modules” by John Clements and Kathi Fisler (Journal of Functional Programming (2010), 20:3-18 Cambridge University Press, doi:10.1017/S0956796809990281) and found it amazing. Maybe the main reason is that one of their examples is related to developing a domain specific language to capture the creation of computer based testing, a subject which is also important for me in the context of computer assisted learning.

Here’s the abstract:

“Many computer science departments are debating the role of programming languages in the curriculum. These discussions often question the relevance and appeal of programming-languages content for today’s students. In our experience, domain-specific, “little languages” projects provide a compelling illustration of the importance of programming-language concepts. This paper describes projects that prototype mainstream applications such as PowerPoint, TurboTax, and animation scripting. We have used these exercises as modules in non-programming languages courses, including courses for first year students. Such modules both encourage students to study linguistic topics in more depth and provide linguistic perspective to students who might not otherwise be exposed to the area.”

 
Leave a comment

Posted by on September 15, 2010 in Linguistics, Lisp, Programlama

 

Lisp: A Space Odyssey


A funny magazine cover from good ol’ days:

BYTE Magazine cover from August 1979, Volume 4, Number 8: Lisp code on the famous monolith of '2001: A Space Odyssey'

BYTE Magazine cover from August 1979, Volume 4, Number 8: Lisp code on the famous monolith of '2001: A Space Odyssey'

For more info:

http://kazimirmajorinc.blogspot.com/2010/07/cover-of-byte-1979-lisp-issue.html

http://xahlee.org/funny/byte_mag_lisp.html

http://groups.google.com/group/comp.lang.lisp/browse_frm/thread/516417684a3e8f69#

 
1 Comment

Posted by on August 4, 2010 in Lisp, Programlama