20090622 Bp Study#22

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    20090622 Bp Study#22 - Presentation Transcript

    1. 2009 6 28
    2. • • • • 2009 6 28
    3. • • • • • • 2009 6 28
    4. 2009 6 28
    5. 2009 6 28
    6. 2009 6 28
    7. 2009 6 28
    8. 2009 6 28
    9. 2009 6 28
    10. 2009 6 28
    11. 2009 6 28
    12. 2009 6 28
    13. 2009 6 28
    14. 2009 6 28
    15. • • • • • 2009 • 6 28
    16. 2009 6 28
    17. 2009 6 28
    18. • • • • 2009 6 28
    19. • 2009 6 28
    20. 2009 6 28
    21. 2009 6 28
    22. • • • • • 2009 6 28
    23. • • • • • 2009 6 28
    24. 2009 6 28
    25. 2009 6 28
    26. scala>
val
list:List[Int]
=
List(1,2,3,4) list:
List[Int]
=
List(1,
2,
3,
4) scala>
val
list
=
List(1,2,3,4) list:
List[Int]
=
List(1,
2,
3,
4) 2009 6 28
    27. scala>
def
isEven(i:Int):Boolean
=
{ 












return
(
i
%
2
==
0
) 











}



























 isEven:
(Int)Boolean scala>
def
isEven(i:Int)
=
i
%
2
==
0 isEven:
(Int)Boolean scala>
val
func
=
isEven
_ func:
(Int)
=>
Boolean
=
<function> 2009 6 28
    28. scala>
def
add(n:Int)(m:Int)=n+m add:
(n:
Int)(m:
Int)Int scala>
val
add3
=
add(
3
)
_ add3:
(Int)
=>
Int
=
<function> scala>
def
curryingAdd(
n:Int
)
=
add(
n
)
_ curryingAdd:
(Int)(Int)
=>
Int 2009 6 28
    29. scala>
l.map(
{(n:Int)
=>
n
*
2}
) res1:
List[Int]
=
List(2,
4,
6,
8) scala>
list.filter(
_
%
2
==
0
) res2:
List[Int]
=
List(2,
4) scala>
list.filter(
func
)





 res3:
List[Int]
=
List(2,
4) 2009 6 28
    30. def
test[T](list:List[T])
=
list
match
{ 







case
1::xs
=>
print("start
1")







 







case
2::xs
=>
print("start
2")







 







case
"Test"::xs
=>
print("start
Test") 







case
x::Nil
=>
print("one
elemnt")



 







case
x::xs
=>
print("start
"
+
x
)



 







case
_
=>
print("default")











 
}

 2009 6 28
    31. scala>
class
Foo(
val
n:Int,
val
s:String
){



 








def
bar
=
print(
n
+
s
) 






} defined
class
Foo scala>
object
FooObj{


 








val
n
=
3 








val
s
=
"Bar" 








def
bar
=
print(
n
+
s
) 






} defined
module
FooObj 2009 6 28
    32. 2009 6 28
    33. 2009 6 28
    34. 2009 6 28
    35. 2009 6 28
    36. 2009 6 28
    37. • • • 2009 6 28
    38. • • • • 2009 6 28
    39. • 2009 6 28
    40. • • 2009 6 28
    41. • • • 2009 6 28
    42. • • • • 2009 6 28
    43. 2009 6 28
    44. 2009 6 28
    45. 2009 6 28
    46. 2009 6 28
    47. 2009 6 28
    48. • • • • 2009 6 28
    49. 2009 6 28
    50. • <p><lift:helloWorld.howdy
/></p> class
HelloWorld
{ 

def
howdy
=
<span>Welcome
to
helloworld
at
 {new
_root_.java.util.Date}</span> } 2009 6 28
    51. • 2009 6 28
    52. • 2009 6 28
    53. • • 2009 6 28
    54. • <lift:SampleSnipet.add
form="POST"> 



<entry:description
/>
 



<entry:amount
/>
<br
/> 



<entry:submit
/> </lift:
SampleSnipet.add
> 2009 6 28
    55. • class
SampleSnipet
 


def
add
(xhtml
:
NodeSeq)
:
NodeSeq
=
{ 







var
desc
=
"" 







var
amount
=
"0" 







def
processEntryAdd
()
{
...
} 







bind("entry",
xhtml, 











"description"
->
SHtml.text(desc,
desc
=
_), 











"amount"
->
SHtml.text(amount,
amount
=
_), 











"submit"
->
SHtml.submit(Add,
 

















processEntryAdd)) 



} } 2009 6 28
    56. 2009 6 28
    57. • • • • • • 2009 6 28
    58. • ‣ ‣ ‣ • ‣ ‣ ‣ 2009 6 28
    59. 2009 6 28
    60. • class
Expense
extends
LongKeyedMapper[Expense]
with
IdPK
{ 


def
getSingleton
=
Expense 


object
dateOf
extends
MappedDateTime(this) 


object
description
extends
MappedString(this,100) 


object
amount
extends
MappedDecimal(this, 








MathContext.DECIMAL64,
2) 


object
account
extends
 





MappedLongForeignKey(this,
Account) } 2009 6 28
    61. • object
Expense
extends
Expense
with
 LongKeyedMetaMapper[Expense]
{ override
def
fieldOrder
=
 




List(dateOf,
description,
amount) } 2009 6 28
    62. • val
myEntries1
=
Expense.findAll

 val
myEntries2
=
Expense.findAll(By_>(Expense.amout,5)
)
 val
recentEntries
=
Expense.findAll( 

BySql("dateOf
>
(CURRENT_DATE
-
interval
’30
days’)", 

IHaveValidatedThisSQL("dchenbecker","2008-12-03")) 2009 6 28
    63. • var
myEntr=
Expense.create myEntry.dateOf(new
Date).description("A
sample
entry") myEntry.amount(BigDecimal("127.20")) myEntry.save myEntry.delete 2009 6 28
    64. 2009 6 28
    65. • • • • 2009 6 28
    66. • • • • 2009 6 28
    67. • • • 2009 6 28
    68. 2009 6 28
    69. • • • • 2009 6 28
    70. • • • 2009 6 28
    71. 2009 6 28
    72. 2009 6 28
    SlideShare Zeitgeist 2009

    + yuroyoroyuroyoro Nominate

    custom

    665 views, 0 favs, 4 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 665
      • 458 on SlideShare
      • 207 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 9
    Most viewed embeds
    • 201 views on http://d.hatena.ne.jp
    • 4 views on http://74.125.153.132
    • 1 views on http://reader.freerss.net
    • 1 views on http://k.hatena.ne.jp

    more

    All embeds
    • 201 views on http://d.hatena.ne.jp
    • 4 views on http://74.125.153.132
    • 1 views on http://reader.freerss.net
    • 1 views on http://k.hatena.ne.jp

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?