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
(ns rpn | |
(:require [clojure.edn :as edn])) | |
(deftype Pair [f s]) | |
(defn push' [top value] | |
(Pair. top value)) | |
(defn empty'? [stack] | |
(= stack nil)) |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
/// --- STACK DEFINITION --- | |
typedef struct node_ { | |
int value; | |
struct node_* last; | |
} stack_node_t; |
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
package com.gabrielfv.sandbox.rpn; | |
import java.util.Scanner; | |
import java.util.Stack; | |
/** | |
* Calculadora RPN interativa. | |
* | |
* RPN = Reverse Polish Notation, ou Notação Polonesa Inversa. | |
* (https://pt.wikipedia.org/wiki/Nota%C3%A7%C3%A3o_polonesa_inversa) |
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
package com.gabrielfv.sandbox.triangle; | |
import java.util.Scanner; | |
public class Triangle { | |
/** | |
* Este programa deve "printar" na tela três tipos de triângulos | |
* cujo tamanho é definido pela entrada do usuário. Os tipos de | |
* triângulo são: |
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
package com.gabrielfv.sandbox6 | |
import android.app.Activity | |
import android.app.Application | |
import android.os.Bundle | |
import android.view.View | |
import android.widget.Toast | |
import dagger.* | |
import javax.inject.Inject |
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
class MainActivity : ComponentActivity(R.layout.activity_main) { | |
private lateinit var viewModel: MainViewModel | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
viewModel = provideViewModel(MainViewModel::class.java) | |
textView.text = "${viewModel.count}" |
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
class MainActivity : ComponentActivity(R.layout.activity_main) { | |
private lateinit var viewModel: MainViewModel | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
viewModel = ViewModelProvider(viewModelStore, ViewModelProvider.NewInstanceFactory()) | |
.get(MainViewModel::class.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
public static ViewModelProvider of(@NonNull FragmentActivity activity, | |
@Nullable Factory factory) { | |
Application application = checkApplication(activity); | |
if (factory == null) { | |
factory = ViewModelProvider.AndroidViewModelFactory.getInstance(application); | |
} | |
return new ViewModelProvider(activity.getViewModelStore(), factory); | |
} |
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
class MainActivity : ComponentActivity(R.layout.activity_main) { | |
private val viewModel = GenericProvider.provide { MainViewModel() } | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
textView.text = "${viewModel.count}" | |
button.setOnClickListener { | |
viewModel.inc() |
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
class MainActivity : ComponentActivity(R.layout.activity_main) { | |
private var count: Int = 0 | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
savedInstanceState?.let { state -> | |
count = state.getInt("COUNT", 0) | |
} |
NewerOlder