SlideShare ist ein Scribd-Unternehmen logo
1 von 72
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

All You Need is Fold in the Key of C#
All You Need is Fold in the Key of C#All You Need is Fold in the Key of C#
All You Need is Fold in the Key of C#Mike Harris
 
R-ggplot2 package Examples
R-ggplot2 package ExamplesR-ggplot2 package Examples
R-ggplot2 package ExamplesDr. Volkan OBAN
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpyFaraz Ahmed
 
SupportVectorRegression
SupportVectorRegressionSupportVectorRegression
SupportVectorRegressionDaniel K
 
R scatter plots
R scatter plotsR scatter plots
R scatter plotsAbhik Seal
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions Dr. Volkan OBAN
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIDr. Volkan OBAN
 
Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)PyData
 
Data Visualization with R.ggplot2 and its extensions examples.
Data Visualization with R.ggplot2 and its extensions examples.Data Visualization with R.ggplot2 and its extensions examples.
Data Visualization with R.ggplot2 and its extensions examples.Dr. Volkan OBAN
 
Python object oriented programming (lab2) (2)
Python object oriented programming (lab2) (2)Python object oriented programming (lab2) (2)
Python object oriented programming (lab2) (2)iloveallahsomuch
 
imager package in R and examples..
imager package in R and examples..imager package in R and examples..
imager package in R and examples..Dr. Volkan OBAN
 

Was ist angesagt? (20)

All You Need is Fold in the Key of C#
All You Need is Fold in the Key of C#All You Need is Fold in the Key of C#
All You Need is Fold in the Key of C#
 
NumPy Refresher
NumPy RefresherNumPy Refresher
NumPy Refresher
 
Stomata Membrane
Stomata MembraneStomata Membrane
Stomata Membrane
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
 
R-ggplot2 package Examples
R-ggplot2 package ExamplesR-ggplot2 package Examples
R-ggplot2 package Examples
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpy
 
SupportVectorRegression
SupportVectorRegressionSupportVectorRegression
SupportVectorRegression
 
R scatter plots
R scatter plotsR scatter plots
R scatter plots
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions
 
Python programing
Python programingPython programing
Python programing
 
Numpy python cheat_sheet
Numpy python cheat_sheetNumpy python cheat_sheet
Numpy python cheat_sheet
 
Hat04 0205
Hat04 0205Hat04 0205
Hat04 0205
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part II
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
 
Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)
 
Data Visualization with R.ggplot2 and its extensions examples.
Data Visualization with R.ggplot2 and its extensions examples.Data Visualization with R.ggplot2 and its extensions examples.
Data Visualization with R.ggplot2 and its extensions examples.
 
Python object oriented programming (lab2) (2)
Python object oriented programming (lab2) (2)Python object oriented programming (lab2) (2)
Python object oriented programming (lab2) (2)
 
Jfreechart tutorial
Jfreechart tutorialJfreechart tutorial
Jfreechart tutorial
 
imager package in R and examples..
imager package in R and examples..imager package in R and examples..
imager package in R and examples..
 
C++ ammar .s.q
C++  ammar .s.qC++  ammar .s.q
C++ ammar .s.q
 

Ähnlich wie 20090622 Bp Study#22

ECMAScript 6, o cómo usar el JavaScript del futuro hoy
ECMAScript 6, o cómo usar el JavaScript del futuro hoyECMAScript 6, o cómo usar el JavaScript del futuro hoy
ECMAScript 6, o cómo usar el JavaScript del futuro hoySoftware Guru
 
Test s velocity_15_5_4
Test s velocity_15_5_4Test s velocity_15_5_4
Test s velocity_15_5_4Kunihiko Saito
 
Prob-Dist-Toll-Forecast-Uncertainty
Prob-Dist-Toll-Forecast-UncertaintyProb-Dist-Toll-Forecast-Uncertainty
Prob-Dist-Toll-Forecast-UncertaintyAnkoor Bhagat
 
Parallel Computing in R
Parallel Computing in RParallel Computing in R
Parallel Computing in Rmickey24
 
Math-Bridge Additional Interactivity
Math-Bridge Additional InteractivityMath-Bridge Additional Interactivity
Math-Bridge Additional Interactivitymetamath
 
QTP Presentation2
QTP Presentation2QTP Presentation2
QTP Presentation2vucevic
 
Esoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in RubyEsoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in Rubymametter
 
第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)
第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)
第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)Wataru Shito
 
Datamining r 4th
Datamining r 4thDatamining r 4th
Datamining r 4thsesejun
 
A practical work of matlab
A practical work of matlabA practical work of matlab
A practical work of matlabSalanSD
 
Idea for ineractive programming language
Idea for ineractive programming languageIdea for ineractive programming language
Idea for ineractive programming languageLincoln Hannah
 
Calculator_workshop-2024_version accept the
Calculator_workshop-2024_version accept theCalculator_workshop-2024_version accept the
Calculator_workshop-2024_version accept theRitchiWit
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonAlex Payne
 
COMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptxCOMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptximman gwu
 
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみたスマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみたTaro Matsuzawa
 
Contrastive Divergence Learning
Contrastive Divergence LearningContrastive Divergence Learning
Contrastive Divergence Learningpenny 梁斌
 

Ähnlich wie 20090622 Bp Study#22 (20)

ECMAScript 6, o cómo usar el JavaScript del futuro hoy
ECMAScript 6, o cómo usar el JavaScript del futuro hoyECMAScript 6, o cómo usar el JavaScript del futuro hoy
ECMAScript 6, o cómo usar el JavaScript del futuro hoy
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
 
Test s velocity_15_5_4
Test s velocity_15_5_4Test s velocity_15_5_4
Test s velocity_15_5_4
 
Prob-Dist-Toll-Forecast-Uncertainty
Prob-Dist-Toll-Forecast-UncertaintyProb-Dist-Toll-Forecast-Uncertainty
Prob-Dist-Toll-Forecast-Uncertainty
 
Parallel Computing in R
Parallel Computing in RParallel Computing in R
Parallel Computing in R
 
Math-Bridge Additional Interactivity
Math-Bridge Additional InteractivityMath-Bridge Additional Interactivity
Math-Bridge Additional Interactivity
 
QTP Presentation2
QTP Presentation2QTP Presentation2
QTP Presentation2
 
Esoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in RubyEsoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in Ruby
 
第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)
第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)
第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)
 
Datamining r 4th
Datamining r 4thDatamining r 4th
Datamining r 4th
 
Do You Have the Time
Do You Have the TimeDo You Have the Time
Do You Have the Time
 
A practical work of matlab
A practical work of matlabA practical work of matlab
A practical work of matlab
 
Java Script Overview
Java Script OverviewJava Script Overview
Java Script Overview
 
Idea for ineractive programming language
Idea for ineractive programming languageIdea for ineractive programming language
Idea for ineractive programming language
 
Calculator_workshop-2024_version accept the
Calculator_workshop-2024_version accept theCalculator_workshop-2024_version accept the
Calculator_workshop-2024_version accept the
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the Horizon
 
COMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptxCOMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptx
 
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみたスマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
 
Part 7
Part 7Part 7
Part 7
 
Contrastive Divergence Learning
Contrastive Divergence LearningContrastive Divergence Learning
Contrastive Divergence Learning
 

Mehr von Tomohito Ozaki

20120804 ll decade lt_yuroyoro
20120804 ll decade lt_yuroyoro20120804 ll decade lt_yuroyoro
20120804 ll decade lt_yuroyoroTomohito Ozaki
 
java-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - Visitor
java-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - Visitorjava-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - Visitor
java-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - VisitorTomohito Ozaki
 
java-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - Interpreter
java-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - Interpreterjava-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - Interpreter
java-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - InterpreterTomohito Ozaki
 
これまでのScala これからのScala (20100904 Scala座#01 )
これまでのScala これからのScala (20100904 Scala座#01 )これまでのScala これからのScala (20100904 Scala座#01 )
これまでのScala これからのScala (20100904 Scala座#01 )Tomohito Ozaki
 
20091008 Jjug Ccc 2009fall
20091008 Jjug Ccc 2009fall20091008 Jjug Ccc 2009fall
20091008 Jjug Ccc 2009fallTomohito Ozaki
 
20090911 Seasar Conference2009 Autumn
20090911 Seasar Conference2009 Autumn20090911 Seasar Conference2009 Autumn
20090911 Seasar Conference2009 AutumnTomohito Ozaki
 
20090613 Seasar Conference2009 Spring
20090613 Seasar Conference2009 Spring20090613 Seasar Conference2009 Spring
20090613 Seasar Conference2009 SpringTomohito Ozaki
 
20090522 Scalaユーザー会#1
20090522 Scalaユーザー会#120090522 Scalaユーザー会#1
20090522 Scalaユーザー会#1Tomohito Ozaki
 
20090306 Wicket勉強会第2回
20090306 Wicket勉強会第2回20090306 Wicket勉強会第2回
20090306 Wicket勉強会第2回Tomohito Ozaki
 
20081128 Bp Study#15 Active Record
20081128 Bp Study#15 Active Record20081128 Bp Study#15 Active Record
20081128 Bp Study#15 Active RecordTomohito Ozaki
 
20081115 Scala勉強会東京#2
20081115 Scala勉強会東京#220081115 Scala勉強会東京#2
20081115 Scala勉強会東京#2Tomohito Ozaki
 
Shibuya.Trac.0.11 Tracとバグ収束曲線?
Shibuya.Trac.0.11 Tracとバグ収束曲線?Shibuya.Trac.0.11 Tracとバグ収束曲線?
Shibuya.Trac.0.11 Tracとバグ収束曲線?Tomohito Ozaki
 

Mehr von Tomohito Ozaki (12)

20120804 ll decade lt_yuroyoro
20120804 ll decade lt_yuroyoro20120804 ll decade lt_yuroyoro
20120804 ll decade lt_yuroyoro
 
java-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - Visitor
java-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - Visitorjava-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - Visitor
java-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - Visitor
 
java-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - Interpreter
java-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - Interpreterjava-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - Interpreter
java-ja 第1回 チキチキ『( ゜ェ゜)・;’.、ゴフッ』 - Interpreter
 
これまでのScala これからのScala (20100904 Scala座#01 )
これまでのScala これからのScala (20100904 Scala座#01 )これまでのScala これからのScala (20100904 Scala座#01 )
これまでのScala これからのScala (20100904 Scala座#01 )
 
20091008 Jjug Ccc 2009fall
20091008 Jjug Ccc 2009fall20091008 Jjug Ccc 2009fall
20091008 Jjug Ccc 2009fall
 
20090911 Seasar Conference2009 Autumn
20090911 Seasar Conference2009 Autumn20090911 Seasar Conference2009 Autumn
20090911 Seasar Conference2009 Autumn
 
20090613 Seasar Conference2009 Spring
20090613 Seasar Conference2009 Spring20090613 Seasar Conference2009 Spring
20090613 Seasar Conference2009 Spring
 
20090522 Scalaユーザー会#1
20090522 Scalaユーザー会#120090522 Scalaユーザー会#1
20090522 Scalaユーザー会#1
 
20090306 Wicket勉強会第2回
20090306 Wicket勉強会第2回20090306 Wicket勉強会第2回
20090306 Wicket勉強会第2回
 
20081128 Bp Study#15 Active Record
20081128 Bp Study#15 Active Record20081128 Bp Study#15 Active Record
20081128 Bp Study#15 Active Record
 
20081115 Scala勉強会東京#2
20081115 Scala勉強会東京#220081115 Scala勉強会東京#2
20081115 Scala勉強会東京#2
 
Shibuya.Trac.0.11 Tracとバグ収束曲線?
Shibuya.Trac.0.11 Tracとバグ収束曲線?Shibuya.Trac.0.11 Tracとバグ収束曲線?
Shibuya.Trac.0.11 Tracとバグ収束曲線?
 

20090622 Bp Study#22

  • 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