Skip to content

Commit 96786f9

Browse files
committed
WIP (Core): Move all sample code from Clojure.Source to new project Clojure.Samples
1 parent dd288ca commit 96786f9

File tree

24 files changed

+993
-1384
lines changed

24 files changed

+993
-1384
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<None Update="clojure\samples\ants.clj">
9+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
10+
</None>
11+
<None Update="clojure\samples\attributes\testattribute.clj">
12+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
13+
</None>
14+
<None Update="clojure\samples\await-test.clj">
15+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
16+
</None>
17+
<None Update="clojure\samples\celsius.clj">
18+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
19+
</None>
20+
<None Update="clojure\samples\counter.clj">
21+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22+
</None>
23+
<None Update="clojure\samples\deftype\testdeftype.clj">
24+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25+
</None>
26+
<None Update="clojure\samples\deftype\testprotocol.clj">
27+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
28+
</None>
29+
<None Update="clojure\samples\dm-test.clj">
30+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
31+
</None>
32+
<None Update="clojure\samples\genclass\testgenclass.clj">
33+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
34+
</None>
35+
<None Update="clojure\samples\genclass\testgenclass2.clj">
36+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
37+
</None>
38+
<None Update="clojure\samples\genclass\testgenclass3.clj">
39+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
40+
</None>
41+
<None Update="clojure\samples\genclass\testmvc.clj">
42+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
43+
</None>
44+
<None Update="clojure\samples\interop\testinterop.clj">
45+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
46+
</None>
47+
<None Update="clojure\samples\proxy\testproxy.clj">
48+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
49+
</None>
50+
<None Update="clojure\samples\stm\teststm.clj">
51+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
52+
</None>
53+
</ItemGroup>
54+
55+
</Project>

Clojure/Clojure.Source/clojure/samples/ants.clj renamed to Clojure/Clojure.Samples/clojure/samples/ants.clj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2-
; Copyright (c) David Miller. All rights reserved.
3-
; The use and distribution terms for this software are covered by the
4-
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
5-
; which can be found in the file epl-v10.html at the root of this distribution.
6-
; By using this software in any fashion, you are agreeing to be bound by
7-
; the terms of this license.
2+
; Copyright (c) David Miller. All rights reserved.
3+
; The use and distribution terms for this software are covered by the
4+
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
5+
; which can be found in the file epl-v10.html at the root of this distribution.
6+
; By using this software in any fashion, you are agreeing to be bound by
7+
; the terms of this license.
88
; You must not remove this notice, or any other, from this software.
99

1010
;dimensions of square world
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
6-
namespace dm
7-
{
8-
// stolen mostly from the MS docs on System.Attribute
9-
10-
public enum Pet
11-
{
12-
Unknown,
13-
Dog,
14-
Cat,
15-
Bird
16-
}
17-
18-
public class PetTypeAttribute : Attribute
19-
{
20-
private Pet _pet;
21-
22-
protected Pet ThePet
23-
{
24-
get { return _pet; }
25-
set { _pet = value; }
26-
}
27-
28-
public PetTypeAttribute(Pet pet)
29-
{
30-
_pet = pet;
31-
}
32-
33-
public override string ToString()
34-
{
35-
return String.Format("<Pet {0}>", _pet.ToString());
36-
}
37-
38-
}
39-
40-
41-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace dm
7+
{
8+
// stolen mostly from the MS docs on System.Attribute
9+
10+
public enum Pet
11+
{
12+
Unknown,
13+
Dog,
14+
Cat,
15+
Bird
16+
}
17+
18+
public class PetTypeAttribute : Attribute
19+
{
20+
private Pet _pet;
21+
22+
protected Pet ThePet
23+
{
24+
get { return _pet; }
25+
set { _pet = value; }
26+
}
27+
28+
public PetTypeAttribute(Pet pet)
29+
{
30+
_pet = pet;
31+
}
32+
33+
public override string ToString()
34+
{
35+
return String.Format("<Pet {0}>", _pet.ToString());
36+
}
37+
38+
}
39+
40+
41+
}
File renamed without changes.
Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
; Copyright (c) Rich Hickey. All rights reserved.
2-
; The use and distribution terms for this software are covered by the
3-
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4-
; which can be found in the file epl-v10.html at the root of this distribution.
5-
; By using this software in any fashion, you are agreeing to be bound by
6-
; the terms of this license.
7-
; You must not remove this notice, or any other, from this software.
8-
;
9-
; Author: David Miller
10-
11-
; Test of gen-class facility.
12-
;
13-
; Place this file in the clojure subdirectory of your main directory.
14-
; Compile the file C.cs via: csc /t:library C.cs
15-
; Place C.dll in your root directory.
16-
; Start Clojure and do:
17-
; (System.Reflection.Assembly/LoadFrom "C.dll")
18-
; (compile 'clojure.testattribute)
19-
;
20-
; You should then be able to play games such as:
21-
22-
(ns clojure.testattribute)
23-
24-
(def x (dm.Pet/Dog))
25-
26-
(gen-interface
27-
:name ^{System.SerializableAttribute {} dm.PetTypeAttribute x} test.I1
28-
:methods [ [m1 [] Object] ])
29-
30-
(definterface ^{System.SerializableAttribute {} dm.PetTypeAttribute x} I2 (m2 []))
31-
32-
; (seq (.GetCustomAttributes test.I1 true))
33-
; (seq (.GetCustomAttributes I2 true))
34-
35-
36-
(definterface ^{ dm.PetTypeAttribute x } I3
37-
(^{ dm.PetTypeAttribute x } m1 [ x y])
38-
(m2 [x ^{ dm.PetTypeAttribute x } y]))
39-
40-
41-
(deftype ^{System.SerializableAttribute {}} T1 [a ^{ dm.PetTypeAttribute x } b]
42-
I3
43-
(^{ dm.PetTypeAttribute x } m1 [_ p q] p)
44-
(m2 [_ p ^{ dm.PetTypeAttribute x } q] q)
1+
; Copyright (c) Rich Hickey. All rights reserved.
2+
; The use and distribution terms for this software are covered by the
3+
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4+
; which can be found in the file epl-v10.html at the root of this distribution.
5+
; By using this software in any fashion, you are agreeing to be bound by
6+
; the terms of this license.
7+
; You must not remove this notice, or any other, from this software.
8+
;
9+
; Author: David Miller
10+
11+
; Test of gen-class facility.
12+
;
13+
; Place this file in the clojure subdirectory of your main directory.
14+
; Compile the file C.cs via: csc /t:library C.cs
15+
; Place C.dll in your root directory.
16+
; Start Clojure and do:
17+
; (System.Reflection.Assembly/LoadFrom "C.dll")
18+
; (compile 'clojure.testattribute)
19+
;
20+
; You should then be able to play games such as:
21+
22+
(ns clojure.testattribute)
23+
24+
(def x (dm.Pet/Dog))
25+
26+
(gen-interface
27+
:name ^{System.SerializableAttribute {} dm.PetTypeAttribute x} test.I1
28+
:methods [ [m1 [] Object] ])
29+
30+
(definterface ^{System.SerializableAttribute {} dm.PetTypeAttribute x} I2 (m2 []))
31+
32+
; (seq (.GetCustomAttributes test.I1 true))
33+
; (seq (.GetCustomAttributes I2 true))
34+
35+
36+
(definterface ^{ dm.PetTypeAttribute x } I3
37+
(^{ dm.PetTypeAttribute x } m1 [ x y])
38+
(m2 [x ^{ dm.PetTypeAttribute x } y]))
39+
40+
41+
(deftype ^{System.SerializableAttribute {}} T1 [a ^{ dm.PetTypeAttribute x } b]
42+
I3
43+
(^{ dm.PetTypeAttribute x } m1 [_ p q] p)
44+
(m2 [_ p ^{ dm.PetTypeAttribute x } q] q)
4545
)
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
; Simple test for await
2-
; Eventually should put in test framework
3-
4-
(def counter (ref 0))
5-
6-
(defn work [state]
7-
(System.Threading.Thread/Sleep 1000)
8-
(dosync (commute counter inc))
9-
true)
10-
11-
(def agents (for [x (range 10)] (agent nil)))
12-
13-
(defn doit []
14-
(doall (map #(send % work) agents))
15-
(apply await agents)
16-
[@counter (doall (map deref agents))])
1+
; Simple test for await
2+
; Eventually should put in test framework
3+
4+
(def counter (ref 0))
5+
6+
(defn work [state]
7+
(System.Threading.Thread/Sleep 1000)
8+
(dosync (commute counter inc))
9+
true)
10+
11+
(def agents (for [x (range 10)] (agent nil)))
12+
13+
(defn doit []
14+
(doall (map #(send % work) agents))
15+
(apply await agents)
16+
[@counter (doall (map deref agents))])

Clojure/Clojure.Source/clojure/samples/celsius.clj renamed to Clojure/Clojure.Samples/clojure/samples/celsius.clj

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
; Copyright (c) David Miller. All rights reserved.
2-
; The use and distribution terms for this software are covered by the
3-
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4-
; which can be found in the file epl-v10.html at the root of this distribution.
5-
; By using this software in any fashion, you are agreeing to be bound by
6-
; the terms of this license.
7-
; You must not remove this notice, or any other, from this software.
8-
9-
10-
;;; A Celsius/Fahrenheit converter
11-
;;; A WinForms equivalent to the Swing app shown here: http://clojure.org/jvm_hosted
12-
13-
; If you are running on .Net 4, you will have to change this.
14-
(System.Reflection.Assembly/Load "System.Windows.Forms,Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
15-
1+
; Copyright (c) David Miller. All rights reserved.
2+
; The use and distribution terms for this software are covered by the
3+
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4+
; which can be found in the file epl-v10.html at the root of this distribution.
5+
; By using this software in any fashion, you are agreeing to be bound by
6+
; the terms of this license.
7+
; You must not remove this notice, or any other, from this software.
8+
9+
10+
;;; A Celsius/Fahrenheit converter
11+
;;; A WinForms equivalent to the Swing app shown here: http://clojure.org/jvm_hosted
12+
13+
; If you are running on .Net 4, you will have to change this.
14+
(System.Reflection.Assembly/Load "System.Windows.Forms,Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
15+
1616
(import
1717
'(System.Drawing Size)
1818
'(System.Windows.Forms
File renamed without changes.

0 commit comments

Comments
 (0)