Getting Started with Eclipse and Counterclockwise

http://dev.clojure.org/display/doc/Getting+Started+with+Eclipse+and+Counterclockwise

Go to start of metadata

 

  • Install Eclipse (If you do not have Eclipse installed, or you want to make isolated tests of the Clojure plugin for Eclipse)
    • Grab the Eclipse ZIP file from http://www.eclipse.org/downloads . If you do not know which "package" to get, pick the "Eclipse IDE for Java Developers" one since it ships out of the box with Git support
    • Unzip it somewhere. The executable is eclipse (linux) or eclipse.exe (windows) located in the eclipse/ directory created by the unzip operation
    • The first time Eclipse is run, it will ask you for a location on your disk where eclipse will put its metadata and will create new projects by default.
  • Install Counterclockwise (the Clojure plugin for Eclipse)
    • You install it via the “software update center”, that is:
    • Menu Help > Install new software…
    • Paste the following Counterclockwise url in the “Work with:” textbox: http://ccw.cgrand.net/updatesite/
    • Hit Enter
    • Select counterclockwise, verify the “Contact all update sites during …” chekbox is checked, click next, accept licence, etc., restart Eclipse
    • Go to menu Window > Reset Perspective ... this will reset the way the views are layout, and also and and place correctly the views contributed by counterclockwise (for now - July 2010 -, the Namespace Browser viewer, placed "behind" the code outline view)
  • Create and run a simple Clojure project (Hello World)
    • Open the Java perspective: Window > Open Perspective > Java (a perspective is a predefined layout of views, suitable for a particular type of development)
    • Create a Clojure project: File > New > Project... > Clojure Project, name it firstClojureProject
    • Create a Clojure source code file in the src/ directory: File > New > File, twist down firstClojureProject in the file creation wizard and select "src" as the ** the parent folder, and name the file helloworld.clj
    • Type code in it to define a function: (defn hello [who] (str "Hello " who " !")) (leave the (ns helloworld) call at the beginning of the file), save the file
    • Run it: Select the firstClojureProject>src>helloworld.clj file, then menu Run > Run as > Clojure REPL. this evaluates the code and starts a REPL
    • Call your function (Hit Ctrl+Enter to send the expression to the REPL server):

      > 1:1 helloworld=> (hello "Betty") [Ctrl+Enter]
      > "Hello Betty !"
      

Installing and running the labrepl environment for learning Clojure

  • If you have installed the "Eclipse IDE for Java Developers" package, you can skip the "Install EGit" and "Install m2e" following steps, since your package already ships with those "Eclipse Features"
  • Install EGit, Git support in Eclipse (optional if you already use another git client)
    • You install it via the “software update center”, that is:
    • Menu Help > Install new software…
    • Paste the following EGit url in the “Work with:” textbox: http://download.eclipse.org/egit/updates
    • Hit Enter
    • Select “Eclipse EGit feature”, verify the “Contact all update sites during …” chekbox is checked, click next, accept licence, etc., restart Eclipse
  • Install m2e, Maven support in Eclipse
    • You install it via the “software update center”, that is:
    • Menu Help > Install new software…
    • Paste the following maven2eclipse (m2e) url in the “Work with:” textbox: http://m2eclipse.sonatype.org/sites/m2e
    • Hit Enter
    • Select Maven Integration for Eclipse, verify the “Contact all update sites during …” chekbox is checked, click next, accept licence, etc., restart Eclipse
    • Note: for Maven, you need to have a JDK installed on your computer (not just a JRE), and configure it as the JVM for use when running Eclipse. (Maven gives a warning when Maven is used.)
  • Grab labrepl from git via EGit
    • Menu File > Import … > Git > Projects From Git; Hit Next
    • URI: git://github.com/relevance/labrepl.git ; Hit Next ; Hit Next ; Check "Import as General Project" ; Hit Finish
  • Enable Clojure Support
    • Right-click the "labrepl" project in Package Explorer and choose "Enable/disable Clojure language support"
  • Run the labrepl
    • Right click on project “labrepl” in the Package Explorer
    • Run as > Clojure REPL
    • In the REPL Console:

      (require 'labrepl)
      (labrepl/-main)
      
    • Open your favorite Browser with URL localhost:8080
    • Enjoy the labs!

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Sure, here's the code: ```cpp #include <iostream> #include <vector> #include <algorithm> using namespace std; void heapify(vector<int>& arr, int n, int i) { int largest = i; int l = 2 * i + 1; int r = 2 * i + 2; if (l < n && arr[l] > arr[largest]) largest = l; if (r < n && arr[r] > arr[largest]) largest = r; if (largest != i) { swap(arr[i], arr[largest]); heapify(arr, n, largest); } } void buildHeap(vector<int>& arr) { int n = arr.size(); for (int i = n / 2 - 1; i >= 0; i--) heapify(arr, n, i); } void printHeap(vector<int>& arr) { int n = arr.size(); int row = 1, col = 0; while (col < n) { for (int i = col; i < min(n, col + row); i++) cout << arr[i] << " "; cout << endl; col += row; row *= 2; } } int main() { vector<int> arr = { 4, 10, 3, 5, 1 }; buildHeap(arr); printHeap(arr); } ``` This program first constructs a max heap from a given vector of integers using the `buildHeap` function. It then prints the heap in a rotated format using the `printHeap` function. The `heapify` function is used to maintain the heap property while constructing the heap. It takes an array `arr`, its size `n`, and the index of the current node `i` as input. It compares the value at the current node with its left and right child nodes, and swaps the current node with the largest child node if necessary. It then recursively calls itself on the largest child node to maintain the heap property. The `buildHeap` function iterates over the second half of the array in reverse order (since these nodes are the ones with children) and calls `heapify` on each node to construct the heap. The `printHeap` function prints the heap in a rotated format. It first initializes the row and column numbers, and then iterates over each row of the heap, printing the nodes in that row and updating the column and row numbers accordingly. Note that this program assumes a complete binary tree representation of the heap. If the input vector is not complete, the program may produce unexpected results.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值