とある断片の超動的言語

906 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
906
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
12
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • とある断片の超動的言語

    1. 1. http://twitter.com/#!/cactusman/status/9123744081510400
    2. 2. gist.githubhttps://gist.github.com/
    3. 3. https://gist.github.com/gists
    4. 4. Groovy
    5. 5. gist 310321File.glob(**/[a-z]*.groovy)
    6. 6. gist 233429
    7. 7. import javax.sound.midi.*def synth = MidiSystem.getSynthesizer()synth.open()def channel = synth.getChannels()[9]channel.noteOn(56, 96)Thread.sleep(100)channel.noteOff(56)synth.close()
    8. 8. gist 250489
    9. 9. score = [ [A2, d4], [A2, d4], [B2, d2], [A2, d4], [A2, d4], [B2, d2], [A2, d4], [B2, d4], [C2, d4], [B2, d4], [A2, d4], [B2, d8], [A2, d8], [F1, d2], [E1, d4], [C1, d4], [E1, d4], [F1, d4], [E1, d4], [E1, d8], [C1, d8], [B1, d2], [A2, d4], [B2, d4], [C2, d4], [B2, d4], [A2, d4], [B2, d8], [A2, d8], [F1, d2], [E1, d4], [C1, d4], [E1, d4], [F1, d4], [E1, d4], [E1, d8], [C1, d8], [B1, d2], [A2, d4], [A2, d4], [B2, d2], [A2, d4], [A2, d4], [B2, d2], [E1, d4], [F1, d4], [B2, d8], [A2, d8], [F1, d4], [E1, d2], [null, d2],]
    10. 10. gist 506855
    11. 11. import hudson.model.*import hudson.slaves.*node = new DumbSlave("testing", "Testing node", "/home/hudson", "2", Node.Mode.NORMAL, "test label", new JNLPLauncher(), new RetentionStrategy.Always(), new ArrayList())hudson.model.Hudson.instance.addNode(node)
    12. 12. gist 702337
    13. 13. gist 524018
    14. 14. Newbie programmerint factorial_newbie(int n) { if (n == 0) { return 1 } else { return n * factorial_newbie(n - 1) }}println factorial_newbie(6)
    15. 15. First year programmer, studied Pascal int factorial_pascal(int n) { int result = 1; for (int i = 1; i <= n; i++) { result = result * i; } return result; } println factorial_pascal(6)
    16. 16. First year programmer, studied C int fact_c(int n) { int result = 1; for (int i = 1; i <= n; i++) { result *= i; } return result; } println fact_c(6)
    17. 17. First year programmer, Python int Factorial_python(int n) { int res = 1 (2..n).each { i -> res *= i } return res } println Factorial_python(6)
    18. 18. Lazy Groovy programmerint fact_lazy(int n) { return (n <= 1) ? 1 : n * fact_lazy(n - 1)}println fact_lazy(6)
    19. 19. Lazier Groovy programmerdef factLazier = { (it <= 1) ? 1 : it * call(it - 1) }println factLazier(6)
    20. 20. Groovy expert programmerdef factExpert = { n -> n ? (1..n).inject(1, { a, b -> a * b }): 1 }println factExpert(6)
    21. 21. Enterprise programmerclass InternalBase { private int base public InternalBase(Integer base) { this.base = base.intValue() } int getBase() { return new Integer(base) }}class StandardMathematicsSystem { private static StandardMathematicsSystem INSTANCE = null private Integer base private StandardMathematicsSystem(InternalBase base) throws RuntimeException { if (base.getBase().compareTo(new Integer(2)) != 0) { throw RuntimeException("Non base 2 bases are not supported.") } this.base = base.getBase() } int calculateFactorial(Integer target) { Integer result = new Integer(1) for (Integer i = new Integer(2); i.compareTo(target) <= 0; i = new Integer(i.intValue() + 1)) { result = result * i } return result } static private StandardMathematicsSystem createInstance(InternalBase base) { return new StandardMathematicsSystem(base) } static StandardMathematicsSystem getInstance(InternalBase base) { if (INSTANCE == null) { INSTANCE = createInstance(base) } return INSTANCE }}println StandardMathematicsSystem.getInstance(new InternalBase(new Integer(2))).calculateFactorial(new Integer(6))
    22. 22. Gist
    23. 23. Gist GGroovy G
    24. 24. gist 326626groovywebconsole.user.jsGist Groovy Greasemonkeyfor Firefox (not for Chrome)
    25. 25. Groovy Gist

    ×