Clojure
(Ns r2.test2(: Gen-class: Methods [# ^ {: static true} [getMessage [String]))
(Defn-getMessage [name](Println (str ("hello" name "! "))))
JAVA end
Import com. ociweb. clj. Demo; // class created by compiling Clojure source file
Public class Main {
Public static void main (String [] args ){String message = Demo. getMessage ("Mark ");System. out. println (message );}}
It seems that you can only use it
Learn how Java next-generation languages reduce boilerplate code and reduce complexity
The limitations faced by the Java programming language at birth are different from those faced by today's developers. Specifically, there are primitive types in the Java language due to the performance and memory limitations of hardware in the middle of the 90 's. Since then, the Java language has evolved, with automatic boxing (Autobox) eliminates a lot of hassle, and the next language (Groovy, Scala, and
Code Path:Https://github.com/bluesilence/Lisp/tree/master/clojure/projects/room-escapeAs I has been a fan of room-escape games, there has always been a desire to make my own story of a Room-escape game. However, I ' m not a UX and don ' t know the much about GUI. So I created the Pure-text room-escape game, with the scalable API for new stories.1. Build the model of aTo begin with, I pictured a draft-class, with nothing but a door and a table.Then the
The core role of microBecause the micro receive parameters can be very complex, and do not evaluate, so you can receive list, in the internal conversion, after processing execution, you can also receive a completely non-Lisp syntax, internally converted to Clojure can execute the list.This allows you to create your own DSL and implement the Clojure macro as a DSL parser.The difference between micro and func
Clojure provides several powerful data structures (collections)I. Types of collections1. VectorEquivalent to an array such as: [2 3 5], ["Ad" "Adas" "Adadsads"]2. ListEquivalent to a linked list, such as: ' (2 3 5), ' ("Ad" "Adas" "Adadsads")Compared to vectors, [] becomes (), and because () the symbol is used for function calls, in order to differentiate, it needs to be preceded by a single quotation mark '3. MapSyntax format such as: {: a 1:b 1}Map
Clojure provides an operation form other than functions and macros. Special form is a limited number and is not implemented by clojure itself.
It mainly includes the following:
Catch, def, do, dot ('.'), finally, FN, if, let, loop,
Monitor-enter, monitor-exit, new, quote, recur, set !, Throw, try, and var.
Complete documentation see: http://clojure.org/special_forms
Vars should be explained here. First,
Label: style Io color OS ar Java for SP
The following content appears in the document on the official website of clojure. This article just summarizes common questions.
1. namespace, Lib, and code file conventions. See the following code:
(nscom.my-company.clojure.examples.my-utils(:importjava.util.Date)(:use[clojure.contrib.def:only(defvar-)])(:require[clojure.contrib.shell-out:asshell]))
Lib is represented as a Java resource. If you have wr
"user=> (time (dorun (pmap inc (range 1 1000))))"Elapsed time: 182.349073 msecs"
Futures and promises
Futures and promises are two slightly more low-level threading constructs, too red by the similar features available in the Java 6 concurrency API. they are simple to understand, simple to use, and provide a very direct way to spawn threads using native clojure syntax.Futures
A clojure future represents a
Http://stackoverflow.com/questions/1314732/scala-vs-groovy-vs-clojureGroovy is a dynamically typed language, whose syntax are very close to Java, with a number of syntax improvements that Allo W for lighter code and less boilerplate. It can run through an interpreter as well as being compiled, which makes it good for fast prototyping, scripts, and Learni ng Dynamic languages without has to learn a new syntax (assuming you know Java). As of Groovy 2.0, it also have growing support for static comp
Clojure-jack-in startup Error
The error message is as follows:
Connecting to swank on port 65280 .. [2 times] Error in process filter: Open-Network-stream: Make client process failed: Connection refused,: Name,Slime lisp,: buffer, nil,: Host, localhost,: Service, 65280,: Nowait, Nil Error in process filter: Make client process failed: Connection refused,: name, slime lisp,: buffer,Nil,: Host, localhost,: Service, 65280,: Nowait, Nil
The sol
clojure-basic syntax-function definitionJuly 21:12 PM1. Create function 1.fn anonymous functionExamples are as follows:"hello")#413e8>"hello"))"hello""hello") ; 带参数"hello"user=>The short function can use # (),% to indicate the unique parameter;% 1,%2. Represents the 1th, 2 、.. A parameter;% represents all parameters, as follows:user=> (#(/ % 3) 4)4/3user=> (#(/ % 3) 4);结果为4/34/3user=> (#(/ %2 %1) 3 4);结果为4/34/3user=> (#(apply / %) 3 5 7);结果为3/5/73/35u
The design of the Java language has been purposefully cut to avoid some problems that have been discovered in the previous generation of products. For example, the designers of the Java language feel that multiple inheritance in C + + poses too much complexity, so they choose not to include the attribute. In fact, they rarely build extensibility options in the language, relying only on single inheritance and interfaces.
Other languages, including the Java Next generation language, have great po
Software development is now a very hot occupation. From 2014 to 2024, demand for developers in the U.S. job market will grow by 17%, compared with a 7% increase in the average demand for all occupations, according to a statistical data released by the U.S. Labor Bureau. Many young people will choose programming as a starting point for their careers. How to learn programming well? How to become a good programmer? How do you plan for a career as a programmer? is a matter of concern to many young p
Ext.: http://www.linuxidc.com/Linux/2012-10/71557.htmFirst of all, I really have to say that there are many tutorials on the internet like JDK7 installed under Ubuntu. However, most are based on the JDK6 bin file. If you go to the Oracle website now and see it, you will find that it has become a. tar.gz compressed file.In addition this article also incidentally gave clojure download link, filename What of please according to your actual situation chan
Code Path:Https://github.com/bluesilence/Lisp/blob/master/clojure/projects/room-escape/src/room_escape/script.cljExtract Stories to TXTIn order to move the stories from. Clj into. txt, I leveraged Clojure ' s eval function. The steps is as follows:1. Read the contents from the story ' s txt as string;2. Eval each key-value pair of each hostel;3. Sort the rooms by name.This works, but isn't good enough. Beca
) Turn off monitoring(Stop Listner)(. Close listener)* * Synchronous Message Queuing with queue implementation(1) Defining Message Queuing(Def sync-q (m/queue "Sync-q")(2) Customizing message answering methods(Def Respinder (M/respond Sync-q Inc)(3) Send a message@ (m/request sync-q 1)Note: The request will wait until the message is answered before it returns, otherwise it remains blocked.* * Implementing asynchronous messages with topic(1) Definition topic(Def t (m/topic "test-topic"))(2) post
Common Methods for clojure map data structure:
Map sorting
(Println (sorted-map-by> 1 "a", 2 "B", 3 "c"); {3 c, 2 B, 1 };; take one equal value (let [results {: A 1: B 2: C 2: D 5: E 1: F 1}] (println (into (sorted-map-by (fn [key1 key2] (compare (get results key2) (get results key1 )))) results); {: D 5,: C 2,: A 1}; all unequal values (let [results {: A 1: B 2: F 4: E 3: D 6: C 5}] (println (into (sorted-map-by (fn [key1 key2] (compare (get result
This article by larrylgq prepared, reproduced please note the Source: http://blog.csdn.net/larrylgq/article/details/7395261
Author: Lu guiqiang
Email: larry.lv.word@gmail.com
Lisp uses special operators to extend the syntax, but the number of special operators in lisp is fixed. To solve this problem, LISP introduces macros, which do not directly do things, but generate actual services.Code.
Evaluate a macro: If the received S-expression is a parameter, a lisp expansion (ecpansion)
Talk about my own background, I am a dabbler programmer, do anything like to know more and try again, I have been exposed to many languages, most of them as tools to useMost of my work now lies in data mining and machine learning, and web development, and the first language I've worked with is Python, where I learned about the concept of functional programming.Speaking of Lisp is said to be a copy of Lisp Python, and learned that the language is from the hacker and painter This book, is said to
4Clojure: 4Clojure Longest ascending sub-sequence algorithmThe description is as follows:
Given a vector of integers, find the longest consecutive sub-sequence of increasing numbers. If the sub-sequences has the same length, use the one of that occurs first. An increasing sub-sequence must has a length of 2 or greater to qualify.
Cases:[1 0 1 2 3 0 4 5] The longest ascending subsequence sequence is [0 1 2 3][5 6 1 3 2 7] The longest ascending subsequence sequence is [5 6] (DEFN t
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.