Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adicionando modificacoes sugeridas por augusto
- Loading branch information
1 parent
4cd0a13
commit a11a34d
Showing
6 changed files
with
75 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
let fun soma x y = x + y in | ||
soma(5,4) | ||
let fun soma x y = x + y, fun suc z = z+1 in | ||
soma(5,suc(1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
Funcional1/src/plp/functional1/memory/ContextoFuncional.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package plp.functional1.memory; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map.Entry; | ||
import java.util.Stack; | ||
|
||
import plp.expressions2.expression.Id; | ||
import plp.expressions2.memory.Ambiente; | ||
import plp.expressions2.memory.Contexto; | ||
import plp.functional1.util.DefFuncao; | ||
|
||
public class ContextoFuncional extends Contexto<DefFuncao> implements Ambiente<DefFuncao> { | ||
|
||
public ContextoFuncional clone() { | ||
ContextoFuncional retorno = new ContextoFuncional(); | ||
|
||
Stack<HashMap<Id, DefFuncao>> novaPilha = new Stack<HashMap<Id, DefFuncao>>(); | ||
|
||
HashMap<Id, DefFuncao> novoMap = new HashMap<Id, DefFuncao>(); | ||
novaPilha.add(novoMap); | ||
|
||
for (HashMap<Id, DefFuncao> map : this.pilha){ | ||
for(Entry<Id, DefFuncao> entry : map.entrySet()){ | ||
novoMap.put(entry.getKey(), entry.getValue()); | ||
} | ||
} | ||
|
||
retorno.setPilha(novaPilha); | ||
|
||
return retorno; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
let var a = fn x y. x + x in | ||
let var a = fn x y. x + y, fun z c = c+c in | ||
a(1,2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters