Kurs Komputerowy S
System Symboliczny
Mathematica

Operacje na ...

... tekstach

StringQ[s]
StringLength[s]
StringReverse[s]
StringTake[s,n]
StringDrop[s,n]
StringInsert[s,nowy,n]
StringPosition[s,tekst]
StringReplace[s,stary->nowy]
StringJoin[s1,s2,...]

s="To jest kurs S";
StringQ[s]

StringLength[s]

StringReverse[s]

StringTake[s,5]

StringTake[s,{5}]

StringDrop[s,5]

StringDrop[s,{5}]

StringInsert[s," komputerowy",13]

StringPosition[s,"kurs"]

StringPosition[s,"s"]

StringReplace[s,"S"->"T"]

StringJoin[s," i T"]

Characters[s]
ToCharacterCode[s]
FromCharacterCode[kod]
LetterQ[s]
DigitQ[s]
UpperCaseQ[s]
LowerCaseQ[s]
ToUpperCase[s]
ToLowerCase[s]
ToString[wyrazenie]
ToExpression[s]
SyntaxQ[s]

Characters[s]

Length[%]

Length[s]

ToCharacterCode[s]

t=48+RandomInteger[9,15]

FromCharacterCode[t]

FromCharacterCode[Range[127-32]+31]

LetterQ[s]

LetterQ["TojestkursS"]

DigitQ["2a"]

DigitQ["54235277"]

ToUpperCase[s]

ToLowerCase[s]

ToString[2+5]

DigitQ[%]

DigitQ[7]

st=ToString[HoldForm[2+5]]

StringLength[%]

SyntaxQ[st]

ToExpression[st]

st1="Solve[x^2-2x==8,x]"

SyntaxQ[st1]

ToExpression[st1]

st2="Solve[x^2-2x==8,x"

SyntaxQ[st2]

... plikach

operacje wysokiego poziomu

Directory[]
SetDirectory[katalog]
ParentDirectory[]

Directory[]

SetDirectory["f:/kks/2009/test"]

ParentDirectory[]

FileNames[wzorzec]
FindFile[plik]
FileExistsQ[plik]

FileNames[]

FileNames["*.txt"]

FindFile["a.txt"]

FileExistsQ["a.inp"]

FileExistsQ["07-Teksty.nb"]

SetDirectory[".."]
FileExistsQ["07-Teksty.nb"]

CopyFile[plik1,plik2]
DeleteFile[plik]

FileNames[]

CopyFile["a.txt","a.inp"]

FileNames[]

DeleteFile["a.inp"]

FileNames[]

FilePrint[plik]
Get[plik]                                   (*   <<   *)
Put[wyrazenie,plik]                 (*   >>   *)
PutAppend[wyrazenie,plik]   (*   >>>   *)
Save[plik,wyrazenie]

SetDirectory["test"]

FilePrint["a.txt"]

a
b

<<a.txt

a
b

f=Expand[(3+2x)^4]

f>>a1.txt

FilePrint["a1.txt"]

g=Simplify[f/(3+2x)]

g>>>a1.txt

FilePrint["a1.txt"]

Save["a2.txt",{f,g}]

FilePrint["a2.txt"]

operacje niskiego poziomu

OpenWrite[plik]
OpenAppend[plik]
Write[strumień,wyrazenie]
WriteString[strumien,tekst]
Close[strumien]

a=OpenWrite["q.txt"]

Write[a,2+x]

Write[a,+3x^2]

Close[a]

FilePrint["q.txt"]

a=OpenWrite["q2.txt"]

WriteString[a,"2+x"]

WriteString[a,"+3x^2"]

Close[a]

FilePrint["q2.txt"]

typy :
Byte
Character
Real
Number
Word
Record
String
Expression

OpenRead[plik]
ReadList[strumien,tekst]
Read[strumień,typ]
StreamPosition[strumien]
SetStreamPosition[strumien,pozycja]
Skip[strumien,typ]
Close[strumien]

a=OpenRead["b.txt"]

ReadList[a,Number]

SetStreamPosition[a,0]

ReadList[a,Number,RecordLists->True]

SetStreamPosition[a,0]
ReadList[a,{Number,Number}]

Close[a]

a=OpenRead["b.txt"]

Read[a,Number]

StreamPosition[a]

Skip[a,Number]

Read[a,Number]

FilePrint["b.txt"]

Close[a]