0
2009   6   28
•
                •

                •
                •

2009   6   28
•
            •
            •
            •
            •

            •
2009   6   28
2009   6   28
2009   6   28
2009   6   28
2009   6   28
2009   6   28
2009   6   28
2009   6   28
2009   6   28
2009   6   28
2009   6   28
2009   6   28
•
       •
       •
       •
       •
2009
       •
       6   28
2009   6   28
2009   6   28
•
           •
           •

           •
2009   6   28
•




2009   6   28
2009   6   28
2009   6   28
•
           •
           •
           •
           •
2009   6   28
•
           •
           •
           •
           •
2009   6   28
2009   6   28
2009   6   28
scala>
val
list:List[Int]
=
List(1,2,3,4)
                list:
List[Int]
=
List(1,
2,
3,
4)


                scala>
val
...
scala>
def
isEven(i:Int):Boolean
=
{
                












return
(
i
%
2
==
0
)
                











}




...
scala>
def
add(n:Int)(m:Int)=n+m
                add:
(n:
Int)(m:
Int)Int

                scala>
val
add3
=
add(
3
)
_
  ...
scala>
l.map(
{(n:Int)
=>
n
*
2}
)
                res1:
List[Int]
=
List(2,
4,
6,
8)

                scala>
list.filter(...
def
test[T](list:List[T])
=
list
match
{
                







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








                

...
scala>
class
Foo(
val
n:Int,
val
s:String
){




                








def
bar
=
print(
n
+
s
)
                






...
2009   6   28
2009   6   28
2009   6   28
2009   6   28
2009   6   28
•
           •
           •

2009   6   28
•
           •
           •
           •

2009   6   28
•



2009   6   28
•


           •
2009   6   28
•

           •
           •
2009   6   28
•
           •
           •
           •
2009   6   28
2009   6   28
2009   6   28
2009   6   28
2009   6   28
2009   6   28
•
           •
           •
           •
2009   6   28
2009   6   28
•
                    <p><lift:helloWorld.howdy
/></p>




                class
HelloWorld
{

                

def
howdy...
•




2009   6   28
•




2009   6   28
•
           •




2009   6   28
•
                <lift:SampleSnipet.add
form="POST">
                



<entry:description
/>

                



<entr...
•
                class
SampleSnipet

                


def
add
(xhtml
:
NodeSeq)
:
NodeSeq
=
{
                







v...
2009   6   28
•
           •
           •
                •
           •
           •
2009   6   28
•
            ‣
            ‣
            ‣

       •
            ‣
            ‣
            ‣

2009   6   28
2009   6   28
•
       class
Expense
extends
LongKeyedMapper[Expense]
with
IdPK
{
       


def
getSingleton
=
Expense
       


object
...
•
           object
Expense
extends
Expense
with

           LongKeyedMetaMapper[Expense]
{
           override
def
fieldO...
•
                val
myEntries1
=
Expense.findAll


                val
myEntries2
=
Expense.findAll(By_>(Expense.amout,5...
•
                var
myEntr=
Expense.create
                myEntry.dateOf(new
Date).description("A
sample
entry")
      ...
2009   6   28
•
           •

           •
           •

2009   6   28
•
           •
           •
           •


2009   6   28
•
           •
           •


2009   6   28
2009   6   28
•
           •

           •
           •
2009   6   28
•
           •
           •

2009   6   28
2009   6   28
2009   6   28
Upcoming SlideShare
Loading in...5
×

20090622 Bp Study#22

1,591

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,591
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
22
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "20090622 Bp Study#22"

  1. 1. 2009 6 28
  2. 2. • • • • 2009 6 28
  3. 3. • • • • • • 2009 6 28
  4. 4. 2009 6 28
  5. 5. 2009 6 28
  6. 6. 2009 6 28
  7. 7. 2009 6 28
  8. 8. 2009 6 28
  9. 9. 2009 6 28
  10. 10. 2009 6 28
  11. 11. 2009 6 28
  12. 12. 2009 6 28
  13. 13. 2009 6 28
  14. 14. 2009 6 28
  15. 15. • • • • • 2009 • 6 28
  16. 16. 2009 6 28
  17. 17. 2009 6 28
  18. 18. • • • • 2009 6 28
  19. 19. • 2009 6 28
  20. 20. 2009 6 28
  21. 21. 2009 6 28
  22. 22. • • • • • 2009 6 28
  23. 23. • • • • • 2009 6 28
  24. 24. 2009 6 28
  25. 25. 2009 6 28
  26. 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. 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. 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. 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. 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. 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. 32. 2009 6 28
  33. 33. 2009 6 28
  34. 34. 2009 6 28
  35. 35. 2009 6 28
  36. 36. 2009 6 28
  37. 37. • • • 2009 6 28
  38. 38. • • • • 2009 6 28
  39. 39. • 2009 6 28
  40. 40. • • 2009 6 28
  41. 41. • • • 2009 6 28
  42. 42. • • • • 2009 6 28
  43. 43. 2009 6 28
  44. 44. 2009 6 28
  45. 45. 2009 6 28
  46. 46. 2009 6 28
  47. 47. 2009 6 28
  48. 48. • • • • 2009 6 28
  49. 49. 2009 6 28
  50. 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. 51. • 2009 6 28
  52. 52. • 2009 6 28
  53. 53. • • 2009 6 28
  54. 54. • <lift:SampleSnipet.add
form="POST"> 



<entry:description
/>
 



<entry:amount
/>
<br
/> 



<entry:submit
/> </lift:
SampleSnipet.add
> 2009 6 28
  55. 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. 56. 2009 6 28
  57. 57. • • • • • • 2009 6 28
  58. 58. • ‣ ‣ ‣ • ‣ ‣ ‣ 2009 6 28
  59. 59. 2009 6 28
  60. 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. 61. • object
Expense
extends
Expense
with
 LongKeyedMetaMapper[Expense]
{ override
def
fieldOrder
=
 




List(dateOf,
description,
amount) } 2009 6 28
  62. 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. 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. 64. 2009 6 28
  65. 65. • • • • 2009 6 28
  66. 66. • • • • 2009 6 28
  67. 67. • • • 2009 6 28
  68. 68. 2009 6 28
  69. 69. • • • • 2009 6 28
  70. 70. • • • 2009 6 28
  71. 71. 2009 6 28
  72. 72. 2009 6 28
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×