20090622 Bp Study#22
Upcoming SlideShare
Loading in...5
×
 

20090622 Bp Study#22

on

  • 2,824 views

 

Statistics

Views

Total Views
2,824
Views on SlideShare
2,264
Embed Views
560

Actions

Likes
0
Downloads
21
Comments
0

7 Embeds 560

http://d.hatena.ne.jp 440
http://yuroyoro.hatenablog.com 105
http://www.slideshare.net 8
http://74.125.153.132 4
http://reader.freerss.net 1
http://k.hatena.ne.jp 1
http://webcache.googleusercontent.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

20090622 Bp Study#22 20090622 Bp Study#22 Presentation Transcript

  • 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
list
=
List(1,2,3,4) list:
List[Int]
=
List(1,
2,
3,
4) 2009 6 28
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
=
<span>Welcome
to
helloworld
at
 {new
_root_.java.util.Date}</span> } 2009 6 28
  • • 2009 6 28
  • • 2009 6 28
  • • • 2009 6 28
  • • <lift:SampleSnipet.add
form="POST"> 



<entry:description
/>
 



<entry:amount
/>
<br
/> 



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




List(dateOf,
description,
amount) } 2009 6 28
  • • 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
  • • var
myEntr=
Expense.create myEntry.dateOf(new
Date).description("A
sample
entry") myEntry.amount(BigDecimal("127.20")) myEntry.save myEntry.delete 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