2008年11月16日 星期日

LISP 初體驗

原本以為 LISP 只是一個普通的 functional language,所以之前都沒去接觸。但是在看完<<駭客與畫家>>之後,開始對 LISP 產生興趣。

書裡面提到 LISP 擁有許多最近新語言開始導入的 feature,而 LISP 也擁有一些其他語言沒有的功能。像我主要是被 LISP 的 macro 吸引(比 C 的 macro 強大多了。可以先把他想像成是 return 程式碼的 function,而且是在 compile 前先展開。),所以開始看 <<Practical Common Lisp>> 一書。目前為止,大家比較熟悉的語言中,我只有在 Perl 6 裡面看到 (http://en.wikipedia.org/wiki/Perl_6#Macros)。

大部分的人對 LISP 的印象就是一堆噁心的括號,寫個加法都要用 (+ 1 2) 這種前置式來敘述,實在是不符合人類的直覺。而 LISP 整個程式碼都是這樣 -- 由一堆 "list" 所組成。(* (+ 1 2) (+ 3 4)) 有一個 list,第一個元素是 * 這個 "function",第二、三個是另外兩個 list。類似這樣的語法,在定義 function、if、while 等等都一樣。

但這之前隱含了一件事實:LISP 本身的程式碼,就是一個資料結構! 所以 LISP 的 macro 做的事情就是生出程式碼的資料結構,我覺得這就比 Perl 6 的 macro 那種 template 的方式優雅多了。不過,這個優點是建立在令人卻步的括號海上的...

接下來,po 幾個我的 LISP 練習 XD

21 則留言:

Unknown 提到...

請問ptt留下的不良對罵紀錄能否刪除?

Unknown 提到...

可以幫我刪除嗎?我不是有意的

카지노사이트위키 提到...

I learned a lot in this blog. Thank you very much for sharing good content.

온라인카지노 提到...

Useful blog info. Keep blogging! I wanted to thank you for this excellent read!

카지노사이트탑 提到...

I will support you. Such a very useful article. A must read post

카지노사이트킹 提到...

It’s really a nice and useful piece of information that you provide.

William Stephen 提到...

I appreciate your effort for publishing such an amazing article. It is very effective and interesting. Thanks for sharing. reckless driving in virginia

Antony 提到...

Strategic defense against federal charges and protection of your rights are provided by an experienced federal criminal defense lawyer in Maryland. Our focus on federal law guarantees professionalism and knowledge in the federal courts of Maryland. Put your trust in us to protect your future and get the best possible result in court.
Federal Criminal Defense Lawyer Maryland

Unknown 提到...

Exploring Divorce Lawyer Fairfax VA Free Consultation with our dedicated divorce lawyer. We're here to offer guidance and support tailored to your needs. Contact us now to take the first step towards a new chapter in your life!

Richard 提到...

Great blog! I had a great time reading this post because it was so informative. Thank you for sharing. Fairfax DUI Lawyer

Lee 提到...

Lisp, a family of programming languages, was developed by John McCarthy at the Massachusetts Institute of Technology (MIT) in the late 1950s as a language for artificial intelligence research. It is known for its unique feature of treating code as data and vice versa, making it highly flexible and powerful. Key features of Lisp include S-expression syntax, which uses symbolic expressions in nested lists, and the common structure of code and data, enabling powerful metaprogramming capabilities. Lisp is dynamically typed, meaning variable type is determined at runtime, providing flexibility but potentially leading to runtime errors. Memory management is typically handled through garbage collection, which automatically reclaims memory that is no longer in use. Lisp supports functional programming paradigms, including first-class functions and recursion. Two well-known dialects of Lisp are Common Lisp and Scheme, with Common Lisp being a standardized version with a broad feature set and Scheme being known for its simplicity and minimalist design.accidentes de moto ayer

martin03481 提到...

Lisp is a programming language with a distinctive syntax, primarily characterized by the use of parentheses. This syntax can be intimidating initially, but it also enables the manipulation of code as data, allowing for powerful metaprogramming possibilities. Lisp's macros generate the data structure of program code, allowing for more concise and expressive programs. The syntax's simplicity and consistency make it a visual aid in understanding code structure. Lisp's emphasis on code as data aligns with the idea of homoiconicity, where the program's syntax is a subset of its data structures. Comparing Lisp's macros with Perl 6's is interesting, as each language approaches metaprogramming differently. Understanding these differences can deepen one's understanding of programming languages and broaden their toolkit for solving various problems. Charlottesville Virginia Abogados de Lesiones Personales

lanisterjimmy 提到...

It seems like you've mentioned "Lisp."
Lisp is a family of programming languages known for their unique and expressive syntax.
Here are a few lines of information about Lisp:1. **
Historical Significance:** "Lisp, short for List Processing, is a family of programming languages with deep historical significance.
Developed in the late 1950s, it remains influential in the world of programming languages.
Expressive Syntax:** "Lisp is renowned for its simple and expressive syntax, characterized by parentheses and a distinctive notation.
This unique structure contributes to its power and flexibility.
"3. **
Functional Programming Roots:** "At its core, Lisp is a functional programming language.
It pioneered many concepts, such as first-class functions and dynamic typing, which are now fundamental in modern programming languages.
Common Lisp:** "Common Lisp, one of the major dialects of Lisp, is a standardized version that combines the strengths of earlier Lisp dialects.
It is known for its extensibility and features for symbolic computation.
AI and Lisp:** "Lisp has played a significant role in the development of artificial intelligence.
Its adaptability and support for symbolic reasoning made it a natural choice for AI research and development.
Interactive Development:** "Lisp environments are often highly interactive, allowing developers to redefine functions and experiment with code on the fly.
This interactive development style is a hallmark of Lisp programming.
"7. **
Macros and Metaprogramming:** "Lisp's macro system enables powerful metaprogramming capabilities, allowing developers to define domain-specific languages and extend the language itself.
Influence on Other Languages:** "While not as mainstream as some languages, Lisp has left a lasting impact on the field of programming languages.
Concepts from Lisp, such as garbage collection and lexical closures, have influenced numerous languages.trucking accident law firm

lanisterjimmy 提到...

Lisp is a family of programming languages developed by John McCarthy in the late 1950s, known for its unique syntax and support for symbolic expressions and symbolic computing. Key features of Lisp include S-expressions, homoionicity, dynamic typing, garbage collection, functional programming, macros, Common Lisp and Scheme, and its applications in artificial intelligence research, symbolic mathematics, and software scripting.

Lisp is dynamically typed, allowing variable types to be determined at runtime. It supports functional programming paradigms, including first-class functions, higher-order functions, and closures. Lisp macros allow developers to define new syntactic constructs, extending the language seamlessly with existing code.

Common Lisp and Scheme are two prominent dialects of Lisp, known for their extensive standard library and features, while Scheme is recognized for its minimalism and simplicity. Lisp has been used in various applications, including artificial intelligence research, symbolic mathematics, and scripting in some software applications.

Emacs Lisp, a dialect of Lisp, is built using Emacs Lisp, allowing users to extend and modify the text editor. Lisp has had a significant influence on the development of programming languages and has inspired features in other languages.abogado litigante patrimonial

Alex 提到...

  divorce law in new jersey
New Jersey divorce laws encompass equitable distribution of assets, alimony, child custody arrangements, and grounds for divorce. Understanding these regulations is crucial when navigating the legal process of ending a marriage.

Lime Emerson 提到...

Excellent blog! Keep share more post. Fairfax VA DUI Defense Lawyer

Rachel 提到...

"divorce lawyers new jersey"
The author describes their first experience with LISP, describing it as fascinating due to its simplicity and elegance, which allowed them to approach problems intuitively and efficiently. They found LISP's flexibility and focus on list manipulation to be a revelation in programming problems. The initial learning curve of LISP can be steep, but as it progresses, they discover its expressive power and the ability to create recursive functions. The author's first immersion in LISP was challenging but gratifying, as it offered a unique perspective on functional programming. The author is eager to explore more LISP.

sansastark 提到...

Lisp, or "List Processing," is a family of programming languages renowned for their unique approach and use of symbolic expressions (S-expressions). Invented by John McCarthy in the late 1950s, Lisp has played a significant role in the development of artificial intelligence and symbolic reasoning. Key characteristics of Lisp include its S-expressions, which represent code and data as nested lists of atoms and sub-lists, and its functional programming, which supports higher-order functions, closures, and recursion. Lisp is dynamically typed, allowing variable data types to be determined at runtime, providing flexibility but requiring careful attention to type-related issues during program execution. It also uses automatic garbage collection to manage memory, making it less explicit and more automated. Lisp's powerful macro system allows developers to define their own language constructs, enabling more expressive code and facilitating metaprogramming. Lisp environments are often interactive, allowing developers to modify and evaluate code on the fly. Two well-known dialects of Lisp are Common Lisp and Scheme, with Common Lisp known for its extensive standard library and Scheme for its simplicity and minimalism. Lisp has historical significance in artificial intelligence, having been implemented in many early AI research projects and expert systems abogado planificación patrimonial.

kolson 提到...


Parallel::ForkManager: A Powerful Tool for Parallel Processing in Perl
Parallel::ForkManager is a popular Perl module that allows you to leverage the power of multiple CPU cores or threads for parallel processing. It provides a convenient way to spawn child processes, manage communication between them, and synchronize their execution. Here's a breakdown of its key features and how it can benefit you:

Benefits:

Increased Performance: By distributing computational tasks across multiple processes, you can significantly speed up applications, especially those involving CPU-intensive calculations or IO-bound operations.
Scalability: Parallel::ForkManager scales well with the number of available cores or threads, allowing you to take advantage of modern multi-core and multi-threaded hardware.
Flexibility: The module offers various approaches to process creation and communication, providing fine-grained control over your parallel processing logic.
Robustness: It includes mechanisms for error handling, process monitoring, and graceful termination, ensuring the stability and reliability of your application.
Key Features:

Forking: Easily create child processes by calling the start method.
Communication: Share data between parent and child processes using pipes, shared memory, or other mechanisms.
Synchronization: Wait for child processes to finish using mechanisms like wait or waitpid.
Callbacks: Execute code after each child process finishes or exits unexpectedly.
Memory Management: Manage memory usage and avoid potential memory leaks in child processes.
Use Cases:

Parallel::ForkManager can be applied to various tasks, including:

Batch processing: Parallel processing large datasets for tasks like data analysis, image processing, or web scraping.
Server-side tasks: Handling multiple client requests concurrently in web applications or servers.
Scientific computing: Performing computationally intensive simulations or calculations.
Build automation: Parallelizing build processes for software projects.
Challenges and Considerations:

While powerful, Parallel::ForkManager also presents some challenges:

Complexity: It requires careful design and understanding of parallelism concepts to avoid issues like race conditions or deadlocks.
Debugging: Debugging parallel code can be more complex than single-threaded code.
Resource Management: Overusing child processes can overload the system, so memory and CPU usage should be monitored.
Alternatives:

Several other Perl modules offer parallel processing capabilities, such as:

Parallel::Threads: Uses lightweight threads instead of processes, better suited for CPU-bound tasks within a single core.
AnyEvent: An event-driven framework that can be used for parallel I/O operations.
Concurrent::Perl: A higher-level abstraction for parallel programming.
truck driver accidents

walterwhite 提到...

Lisp is a family of computer programming languages known for its unique syntax and powerful features, particularly in symbolic computation and artificial intelligence. It stands for "LISt Processing" and manipulates symbolic expressions as lists. Lisp has been influential in programming language development and has applications in AI research, natural language processing, and software development. If you have specific questions about Lisp programming, its history, or applications, feel free to ask Abogado DUI Fairfax.

johnsy 提到...

In Virginia traffic court, reckless driving carries severe penalties. Fines, license suspensions, or even jail time are examples of penalties. For appropriate legal advice, speaking with an attorney is essential.
virginia traffic court reckless driving